diff --git a/plugin/AVideoPlugin.php b/plugin/AVideoPlugin.php index 918753dd1..24394e64a 100644 --- a/plugin/AVideoPlugin.php +++ b/plugin/AVideoPlugin.php @@ -1,2052 +1,2067 @@ $timeLimit) { _error_log("The plugin [{$pluginName}] takes {$total_time} seconds to complete. URL: " . getSelfURI() . " IP: " . getRealIpAddr(), AVideoLog::$WARNING); } } public static function addRoutes() { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->addRoutes(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return false; } public static function addView($videos_id, $total) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->addView($videos_id, $total); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return false; } public static function getHeadCode() { $plugins = Plugin::getAllEnabled(); $str = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $str .= $p->getHeadCode(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $str; } public static function getChartTabs() { $plugins = Plugin::getAllEnabled(); $str = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { if (method_exists($p, 'getChartTabs')) { $str .= $p->getChartTabs(); } else { $checkStr = $p->getChartContent(); if (!empty($checkStr)) { $str .= '
  • ' . $p->getName() . '
  • '; } } } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $str; } public static function getChartContent() { $plugins = Plugin::getAllEnabled(); $str = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $checkStr = $p->getChartContent(); if (!empty($checkStr)) { $str .= '
    ' . $checkStr . '
    '; } } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $str; } public static function getGallerySection() { $plugins = Plugin::getAllEnabled(); $str = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $str .= $p->getGallerySection(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $str; } public static function getHelpToc() { $plugins = Plugin::getAllEnabled(); $str = "

    " . __("Table of content") . "

    "; } public static function getHelp() { $plugins = Plugin::getAllEnabled(); $str = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $t = $p->getHelp(); $str .= $t; if (!empty($t)) { $str .= "
    "; } } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $str; } public static function getFooterCode() { $plugins = Plugin::getAllEnabled(); $str = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $str .= PHP_EOL . "" . PHP_EOL; $str .= $p->getFooterCode(); $str .= PHP_EOL . "" . PHP_EOL; } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $str; } public static function getJSFiles() { $plugins = Plugin::getAllEnabled(); $allFiles = array(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $js = $p->getJSFiles(); if (is_array($js)) { $allFiles = array_merge($allFiles, $js); } } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $allFiles; } public static function getCSSFiles() { $plugins = Plugin::getAllEnabled(); $allFiles = array(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $allFiles = array_merge($allFiles, $p->getCSSFiles()); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $allFiles; } public static function getHTMLBody() { $plugins = Plugin::getAllEnabled(); $str = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $str .= $p->getHTMLBody(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $str; } public static function getHTMLMenuLeft() { $plugins = Plugin::getAllEnabled(); $str = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $str .= $p->getHTMLMenuLeft(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $str; } public static function getHTMLMenuRight() { $plugins = Plugin::getAllEnabled(); $str = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $str .= $p->getHTMLMenuRight(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $str; } public static function getFirstPage() { return static::getEnabledFirstPage(); } public static function getEnabledFirstPage() { $plugins = Plugin::getAllEnabled(); $firstPage = false; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (!is_object($p)) { continue; } $fp = $p->getFirstPage(); if (!empty($fp)) { $firstPage = $fp; } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $firstPage; } static function loadPlugin($name, $forceReload = false) { global $global, $pluginIsLoaded; if (empty($pluginIsLoaded)) { $pluginIsLoaded = array(); } $loadPluginFile = "{$global['systemRootPath']}plugin/{$name}/{$name}.php"; // need to add dechex because some times it return an negative value and make it fails on javascript playlists if (!isset($pluginIsLoaded[$name]) && empty($forceReload)) { $pluginIsLoaded[$name] = false; if (file_exists($loadPluginFile)) { require_once $loadPluginFile; if (class_exists($name)) { $code = "\$p = new {$name}();"; eval($code); if (is_object($p)) { $pluginIsLoaded[$name] = $p; } else { _error_log("[loadPlugin] eval failed for plugin ($name) code ($code) code result ($codeResult) included file $loadPluginFile", AVideoLog::$ERROR); } } } } return $pluginIsLoaded[$name]; } static function loadPluginIfEnabled($name) { $p = static::loadPlugin($name); if ($p) { $uuid = $p->getUUID(); if (static::isEnabled($uuid)) { return $p; } } return false; } static function isPluginTablesInstalled($name, $installIt = false) { global $global, $isPluginTablesInstalled; $name = self::fixName($name); $installSQLFile = "{$global['systemRootPath']}plugin/{$name}/install/install.sql"; if (isset($isPluginTablesInstalled[$installSQLFile])) { return $isPluginTablesInstalled[$installSQLFile]; } //_error_log("isPluginTablesInstalled: Check for {$installSQLFile}"); if (!file_exists($installSQLFile)) { $isPluginTablesInstalled[$installSQLFile] = true; return $isPluginTablesInstalled[$installSQLFile]; } $lines = file($installSQLFile); foreach ($lines as $line) { $pattern1 = "/CREATE TABLE IF NOT EXISTS `?([a-z0-9_]+)[` (]?/i"; $pattern2 = "/CREATE TABLE[^`]+`?([a-z0-9_]+)[` (]?/i"; if (preg_match($pattern1, $line, $matches)) { if (!empty($matches[1])) { //_error_log("isPluginTablesInstalled: Found ({$matches[1]})"); if (!ObjectYPT::isTableInstalled($matches[1])) { //_error_log("isPluginTablesInstalled: ({$matches[1]}) is NOT installed"); if ($installIt) { sqlDAL::executeFile($installSQLFile); return self::isPluginTablesInstalled($name); } else { //_error_log("isPluginTablesInstalled: You need to install table {$matches[1]} for the plugin ({$name})", AVideoLog::$ERROR); $isPluginTablesInstalled[$installSQLFile] = false; return $isPluginTablesInstalled[$installSQLFile]; } } else { //_error_log("isPluginTablesInstalled: ({$matches[1]}) is installed"); } } } else if (preg_match($pattern2, $line, $matches)) { if (!empty($matches[1])) { if (!ObjectYPT::isTableInstalled($matches[1])) { _error_log("You need to install table {$matches[1]} for the plugin ({$name})", AVideoLog::$ERROR); $isPluginTablesInstalled[$installSQLFile] = false; return $isPluginTablesInstalled[$installSQLFile]; } } } } $isPluginTablesInstalled[$installSQLFile] = true; return $isPluginTablesInstalled[$installSQLFile]; } static function getObjectData($name) { return self::getDataObject($name); } static function getDataObject($name) { global $pluginGetDataObject; if (!isset($pluginGetDataObject)) { $pluginGetDataObject = array(); } if (!empty($pluginGetDataObject[$name])) { return $pluginGetDataObject[$name]; } $p = static::loadPlugin($name); if ($p) { $pluginGetDataObject[$name] = $p->getDataObject(); return $pluginGetDataObject[$name]; } return false; } static function getObjectDataIfEnabled($name) { return self::getDataObjectIfEnabled($name); } static function getDataObjectIfEnabled($name) { global $_getDataObjectIfEnabled; if (!isset($_getDataObjectIfEnabled)) { $_getDataObjectIfEnabled = array(); } if (isset($_getDataObjectIfEnabled[$name])) { return $_getDataObjectIfEnabled[$name]; } $p = static::loadPlugin($name); if ($p) { $uuid = $p->getUUID(); if (static::isEnabled($uuid)) { $_getDataObjectIfEnabled[$name] = static::getObjectData($name); return $_getDataObjectIfEnabled[$name]; } } $_getDataObjectIfEnabled[$name] = false; return $_getDataObjectIfEnabled[$name]; } static function xsendfilePreVideoPlay() { $plugins = Plugin::getAllEnabled(); $str = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $str .= $p->xsendfilePreVideoPlay(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $str; } static function getVideosManagerListButton() { $plugins = Plugin::getAllEnabled(); $str = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $str .= $p->getVideosManagerListButton(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $str; } static function getVideosManagerListButtonTitle() { $plugins = Plugin::getAllEnabled(); $str = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $str .= $p->getVideosManagerListButtonTitle(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $str; } static function getUsersManagerListButton() { $plugins = Plugin::getAllEnabled(); $str = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $str .= $p->getUsersManagerListButton(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $str; } static function getWatchActionButton($videos_id) { $plugins = Plugin::getAllEnabled(); $str = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $str .= $p->getWatchActionButton($videos_id); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $str; } static function getNetflixActionButton($videos_id) { $plugins = Plugin::getAllEnabled(); $str = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $str .= $p->getNetflixActionButton($videos_id); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $str; } static function getGalleryActionButton($videos_id) { $plugins = Plugin::getAllEnabled(); $str = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $str .= $p->getGalleryActionButton($videos_id); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $str; } public static function isEnabled($uuid) { return !empty(Plugin::getEnabled($uuid)); } public static function exists($name) { global $global; $name = self::fixName($name); $filename = "{$global['systemRootPath']}plugin/{$name}/{$name}.php"; return file_exists($filename); } static function isEnabledByName($name, $minVersion = '') { global $isPluginEnabledByName; if (empty($isPluginEnabledByName)) { $isPluginEnabledByName = array(); } $index = "{$name}_{$minVersion}"; if (!isset($isPluginEnabledByName[$index])) { $p = static::loadPluginIfEnabled($name); $isPluginEnabledByName[$index] = false; if ($minVersion) { if(!empty($p)){ if(version_compare($p->getPluginVersion(), $minVersion, '>=')){ $isPluginEnabledByName[$index] = true; }else{ _error_log("You need to update your plugin {$name} to version {$minVersion} or greater", AVideoLog::$WARNING); } } } else { $isPluginEnabledByName[$index] = !empty($p); } } return $isPluginEnabledByName[$index]; } static function getLogin() { $plugins = Plugin::getAllEnabled(); $logins = array(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $l = $p->getLogin(); if (is_string($l) && file_exists($l)) { // it is a login form $logins[] = $l; } else if (!empty($l->type)) { // it is a hybridauth $logins[] = array('parameters' => $l, 'loginObject' => $p); } } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $logins; } public static function getStart() { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { //self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->getStart(); } //self::YPTend("{$value['dirName']}::".__FUNCTION__); } } public static function getEnd() { $plugins = Plugin::getAllEnabled(); usort($plugins, function($a, $b) { if ($a['name'] == 'Cache') { return 1; } else if ($b['name'] == 'Cache') { return -1; } return 0; }); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { //_error_log("{$value['dirName']}::" . __FUNCTION__); $p->getEnd(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } } public static function afterVideoJS() { $plugins = Plugin::getAllEnabled(); $r = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $r .= $p->afterVideoJS(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $r; } public static function afterNewVideo($videos_id) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->afterNewVideo($videos_id); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } } public static function afterDonation($from_users_id, $how_much, $videos_id, $users_id) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->afterDonation($from_users_id, $how_much, $videos_id, $users_id); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } } public static function afterNewComment($comments_id) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->afterNewComment($comments_id); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } } public static function afterNewResponse($comments_id) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->afterNewResponse($comments_id); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } } public static function getChannelButton() { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->getChannelButton(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } } public static function getVideoManagerButton() { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->getVideoManagerButton(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } } public static function getLivePanel() { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->getLivePanel(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } } public static function getModeYouTube($videos_id) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->getModeYouTube($videos_id); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } } public function getModeLive($key) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->getModeLive($key); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } } public function getModeLiveLink($liveLink_id) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->getModeLiveLink($liveLink_id); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } } public static function getModeYouTubeLive($users_id) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->getModeYouTubeLive($users_id); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } } public static function getEmbed($videos_id) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->getEmbed($videos_id); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } } public static function getChannel($user_id, $user) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->getChannel($user_id, $user); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } } public static function getLiveApplicationArray() { $plugins = Plugin::getAllEnabled(); $array = array(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $appArray = $p->getLiveApplicationArray(); $array = array_merge($array, $appArray); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $array; } public static function getPlayListButtons($playlist_id = "") { if (empty($playlist_id)) return ""; $plugins = Plugin::getAllEnabled(); $str = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $str .= $p->getPlayListButtons($playlist_id); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $str; } public static function getMyAccount($users_id = "") { if (empty($users_id)) return ""; $plugins = Plugin::getAllEnabled(); $str = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $str .= $p->getMyAccount($users_id); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $str; } public static function getPluginUserOptions() { $plugins = Plugin::getAllEnabled(); $userOptions = array(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $userOptions = array_merge($userOptions, $p->getUserOptions()); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $userOptions; } /** * * @return type return a list of IDs of the user groups */ public static function getDynamicUserGroupsId($users_id) { $plugins = Plugin::getAllEnabled(); $array = array(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $appArray = $p->getDynamicUserGroupsId($users_id); $array = array_merge($array, $appArray); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $array; } public static function getDynamicUsersId($users_groups_id) { $plugins = Plugin::getAllEnabled(); $array = array(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $appArray = $p->getDynamicUsersId($users_groups_id); $array = array_merge($array, $appArray); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $array; } public static function getUserOptions() { $userOptions = static::getPluginUserOptions(); $str = ""; foreach ($userOptions as $userOption => $id) { $str .= "
  • " . __($userOption) . "
  • "; } return $str; } public static function addUserBtnJS() { $userOptions = static::getPluginUserOptions(); $userOptions = array(); $js = ""; foreach ($userOptions as $userOption => $id) { $js .= " $('#$id').prop('checked', false);\n"; } return $js; } public static function updateUserFormJS() { $userOptions = static::getPluginUserOptions(); $js = ""; foreach ($userOptions as $userOption => $id) { $js .= " \"$id\": $('#$id').is(':checked'),\n"; } return $js; } public static function loadUsersFormJS() { $userOptions = static::getPluginUserOptions(); $js = ""; foreach ($userOptions as $userOption => $id) { $js .= " $('#$id').prop('checked', (row.$id == \"1\" ? true : false)); \n"; } return $js; } public static function navBarButtons() { $plugins = Plugin::getAllEnabled(); $userOptions = array(); $navBarButtons = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $navBarButtons .= $p->navBarButtons(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $navBarButtons; } public static function navBarProfileButtons() { $plugins = Plugin::getAllEnabled(); $userOptions = array(); $navBarButtons = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $navBarButtons .= $p->navBarProfileButtons(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $navBarButtons; } public static function navBar() { $plugins = Plugin::getAllEnabled(); $userOptions = array(); $navBarButtons = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $navBarButtons .= $p->navBar(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $navBarButtons; } + public static function navBarAfter() { + $plugins = Plugin::getAllEnabled(); + $userOptions = array(); + $navBarButtons = ""; + foreach ($plugins as $value) { + self::YPTstart(); + $p = static::loadPlugin($value['dirName']); + if (is_object($p)) { + $navBarButtons .= $p->navBarAfter(); + } + self::YPTend("{$value['dirName']}::" . __FUNCTION__); + } + return $navBarButtons; + } + /** * excecute update function at plugin and * update plugin version at database */ public static function updatePlugin($name) { $p = static::loadPlugin($name); if (empty($p)) { return false; } $currentVersion = $p->getPluginVersion(); $uuid = $p->getUUID(); _error_log("AVideoPlugin::updatePlugin name=($name) uuid=($uuid) "); if (method_exists($p, 'updateScript')) { _error_log("AVideoPlugin::updatePlugin method_exists ", AVideoLog::$WARNING); if ($p->updateScript()) Plugin::setCurrentVersionByUuid($uuid, $currentVersion); else return false; } else { _error_log("AVideoPlugin::updatePlugin method NOT exists ", AVideoLog::$WARNING); Plugin::setCurrentVersionByUuid($uuid, $currentVersion); } return true; } public static function getCurrentVersion($name) { $p = static::loadPlugin($name); $uuid = $p->getUUID(); return Plugin::getCurrentVersionByUuid($uuid); } /** * * @param type $name * @param type $version * @return type * -1 if your plugin is lower, * 0 if they are equal, and * 1 if your plugin is greater. */ public static function compareVersion($name, $version) { $currentVersion = self::getCurrentVersion($name); return version_compare($currentVersion, $version); } public static function getSwitchButton($name) { global $global; $p = static::loadPlugin($name); $btn = ""; if (!empty($p)) { $uid = uniqid(); $btn = '
    '; } return $btn; } public static function getAllVideosExcludeVideosIDArray() { $plugins = Plugin::getAllEnabled(); $array = array(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $array = array_merge($array, $p->getAllVideosExcludeVideosIDArray()); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $array; } public static function userCanUpload($users_id) { if (empty($users_id)) { return false; } $resp = true; $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $can = $p->userCanUpload($users_id); if (!empty($can)) { if ($can < 0) { _error_log("userCanUpload: DENIED The plugin {$value['dirName']} said the user ({$users_id}) can NOT upload a video "); $resp = false; } if ($can > 0) { _error_log("userCanUpload: SUCCESS The plugin {$value['dirName']} said the user ({$users_id}) can upload a video "); return true; } } } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $resp; } public static function userCanWatchVideo($users_id, $videos_id) { global $userCanWatchVideoFunction; if (!isset($userCanWatchVideoFunction)) { $userCanWatchVideoFunction = array(); } if (!isset($userCanWatchVideoFunction[$users_id])) { $userCanWatchVideoFunction[$users_id] = array(); } if (isset($userCanWatchVideoFunction[$users_id][$videos_id])) { return $userCanWatchVideoFunction[$users_id][$videos_id]; } $cacheName = "userCanWatchVideo($users_id, $videos_id)"; $cache = ObjectYPT::getSessionCache($cacheName, 600); if (isset($cache)) { return $cache; } $plugins = Plugin::getAllEnabled(); $resp = Video::userGroupAndVideoGroupMatch($users_id, $videos_id); $video = new Video("", "", $videos_id); if (empty($video)) { _error_log("userCanWatchVideo: the usergroup and the video group does not match, User = $users_id, video = $videos_id)"); $userCanWatchVideoFunction[$users_id][$videos_id] = false; ObjectYPT::setSessionCache($cacheName, false); return false; } // check if the video is for paid plans only if ($video->getOnly_for_paid()) { _error_log("userCanWatchVideo: the video ({$videos_id}) is set Only_for_paid = true)"); $resp = false; } foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $can = $p->userCanWatchVideo($users_id, $videos_id); if (!empty($can)) { if ($can < 0) { _error_log("userCanWatchVideo: DENIED The plugin {$value['dirName']} said the user ({$users_id}) can NOT watch the video ({$videos_id})"); $resp = false; } if ($can > 0) { _error_log("userCanWatchVideo: SUCCESS The plugin {$value['dirName']} said the user ({$users_id}) can watch the video ({$videos_id})"); $userCanWatchVideoFunction[$users_id][$videos_id] = true; ObjectYPT::setSessionCache($cacheName, true); return true; } } } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } if (!empty($users_id)) { _error_log("userCanWatchVideo: No plugins approve user ({$users_id}) watch the video ({$videos_id}) "); } $userCanWatchVideoFunction[$users_id][$videos_id] = $resp; ObjectYPT::setSessionCache($cacheName, $resp); return $resp; } public static function userCanWatchVideoWithAds($users_id, $videos_id) { global $userCanWatchVideoWithAdsFunction; $users_id = intval($users_id); if (!isset($userCanWatchVideoWithAdsFunction)) { $userCanWatchVideoWithAdsFunction = array(); } if (!isset($userCanWatchVideoWithAdsFunction[$users_id])) { $userCanWatchVideoWithAdsFunction[$users_id] = array(); } if (isset($userCanWatchVideoWithAdsFunction[$users_id][$videos_id])) { return $userCanWatchVideoWithAdsFunction[$users_id][$videos_id]; } $plugins = Plugin::getAllEnabled(); $resp = Video::userGroupAndVideoGroupMatch($users_id, $videos_id); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $can = $p->userCanWatchVideoWithAds($users_id, $videos_id); if (!empty($can)) { $resp = $can > 0 ? true : false; if ($resp) { _error_log("userCanWatchVideoWithAds the plugin ({$value['dirName']}) said user ({$users_id}) can watch"); $userCanWatchVideoWithAdsFunction[$users_id][$videos_id] = true; return true; } else { //_error_log("userCanWatchVideoWithAds: users_id = $users_id, videos_id = $videos_id {$value['dirName']} said no"); } } } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } $userCanWatchVideoWithAdsFunction[$users_id][$videos_id] = $resp; return $resp; } public static function showAds($videos_id) { global $_showAds; if (!isset($_showAds)) { $_showAds = array(); } if (isset($_showAds[$videos_id])) { return $_showAds[$videos_id]; } $plugins = Plugin::getAllEnabled(); $resp = true; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $showAds = $p->showAds($videos_id); if (!$showAds) { _error_log("showAds: {$value['dirName']} said NOT to show ads on {$videos_id}"); $_showAds[$videos_id] = false; return false; } } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } $_showAds[$videos_id] = $resp; return $resp; } public static function isPaidUser($users_id) { global $_isPaidUser; if (!isset($_isPaidUser)) { $_isPaidUser = array(); } if (isset($_isPaidUser[$users_id])) { return $_isPaidUser[$users_id]; } $plugins = Plugin::getAllEnabled(); $resp = false; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $isPaidUser = $p->isPaidUser($users_id); if ($isPaidUser) { _error_log("isPaidUser: {$value['dirName']} said {$users_id} is a paid user"); $_isPaidUser[$users_id] = true; return true; } } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } $_isPaidUser[$users_id] = $resp; return $resp; } /** * In case some plugin needs to play a video that is not allowed for some reason. * A plugin can replace the getVideo method from the youtubeMode page * @return type */ public static function getVideo() { $plugins = Plugin::getAllEnabled(); $resp = null; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $video = $p->getVideo(); if (!empty($video)) { return $video; } } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $resp; } public static function onUserSignIn($users_id) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onUserSignIn($users_id); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } } public static function onUserSignup($users_id) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onUserSignup($users_id); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } } public static function onLiveStream($users_id, $live_servers_id) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onLiveStream($users_id, $live_servers_id); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } } public static function onUserSocketConnect() { _mysql_connect(); $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onUserSocketConnect(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } _mysql_close(); } public static function onUserSocketDisconnect() { _mysql_connect(); $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onUserSocketDisconnect(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } _mysql_close(); } public static function thumbsOverlay($videos_id) { $plugins = Plugin::getAllEnabled(); $r = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $r .= $p->thumbsOverlay($videos_id); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $r; } public static function profileTabName($users_id) { $plugins = Plugin::getAllEnabled(); $r = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $r .= $p->profileTabName($users_id); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $r; } public static function profileTabContent($users_id) { $plugins = Plugin::getAllEnabled(); $r = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $r .= $p->profileTabContent($users_id); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $r; } public static function getVideoTags($videos_id) { global $global, $advancedCustom; if (empty($videos_id) || !empty($global['disableVideoTags']) || !empty($advancedCustom->disableVideoTags)) { return array(); } global $_getVideoTags; if (empty($_getVideoTags)) { $_getVideoTags = array(); } if (isset($_getVideoTags[$videos_id])) { $array = $_getVideoTags[$videos_id]; } else { $name = "getVideoTags{$videos_id}"; $array = ObjectYPT::getCache($name, 86400); //_error_log("getVideoTags $name ".(empty($array)?"new":"old")); if (empty($array)) { TimeLogStart("AVideoPlugin::getVideoTags($videos_id)"); $plugins = Plugin::getAllEnabled(); $array = array(); foreach ($plugins as $value) { $TimeLog = "AVideoPlugin::getVideoTags($videos_id) {$value['dirName']} "; TimeLogStart($TimeLog); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $array = array_merge($array, $p->getVideoTags($videos_id)); } TimeLogEnd($TimeLog, __LINE__); } TimeLogEnd("AVideoPlugin::getVideoTags($videos_id)", __LINE__); ObjectYPT::setCache($name, $array); $_getVideoTags[$videos_id] = $array; } else { //$array = object_to_array($array); } } return $array; } public static function deleteVideoTags($videos_id) { if (empty($videos_id)) { return false; } $name = "getVideoTags{$videos_id}"; _error_log("deleteVideoTags {$name}"); ObjectYPT::deleteSessionCache($name); return ObjectYPT::deleteCache($name); } public static function getVideoWhereClause() { $plugins = Plugin::getAllEnabled(); $r = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $r .= $p->getVideoWhereClause(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $r; } public static function getManagerVideosAddNew() { $plugins = Plugin::getAllEnabled(); $r = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $r .= $p->getManagerVideosAddNew(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $r; } public static function saveVideosAddNew($post, $videos_id) { $plugins = Plugin::getAllEnabled(); $r = true; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $r = $p->saveVideosAddNew($post, $videos_id) && $r; } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $r; } public static function getManagerVideosReset() { $plugins = Plugin::getAllEnabled(); $r = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $r .= $p->getManagerVideosReset(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $r; } public static function getManagerVideosEdit() { $plugins = Plugin::getAllEnabled(); $r = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $r .= $p->getManagerVideosEdit(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $r; } public static function getManagerVideosEditField() { $plugins = Plugin::getAllEnabled(); $r = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $r .= $p->getManagerVideosEditField(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $r; } public static function getManagerVideosJavaScripts() { $plugins = Plugin::getAllEnabled(); $r = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $r .= $p->getManagerVideosJavaScripts(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $r; } public static function getManagerVideosTab() { $plugins = Plugin::getAllEnabled(); $r = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $r .= $p->getManagerVideosTab(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $r; } public static function getManagerVideosBody() { $plugins = Plugin::getAllEnabled(); $r = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $r .= $p->getManagerVideosBody(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $r; } public static function getAllVideosArray($videos_id) { $plugins = Plugin::getAllEnabled(); $r = array(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $r = array_merge($r, $p->getAllVideosArray($videos_id)); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $r; } public static function getUploadMenuButton() { $plugins = Plugin::getAllEnabled(); $r = ""; foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $r .= $p->getUploadMenuButton(); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return $r; } public static function dataSetup() { $plugins = Plugin::getAllEnabled(); $r = array(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $data = $p->dataSetup(); if (!empty($data)) { $r[] = $data; } } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return implode(",", $r); } /* Video properties hooks */ public static function onVideoSetLive_transmitions_history_id($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetLive_transmitions_history_id($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetEncoderURL($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetEncoderURL($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetFilepath($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetFilepath($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetFilesize($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetFilesize($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetUsers_id($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetUsers_id($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetSites_id($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetSites_id($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetVideo_password($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetVideo_password($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetClean_title($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetClean_title($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetDuration($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetDuration($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetIsSuggested($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetIsSuggested($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetStatus($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetStatus($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetType($video_id, $oldValue, $newValue, $force) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetType($video_id, $oldValue, $newValue, $force); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetRotation($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetRotation($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetZoom($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetZoom($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetDescription($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetDescription($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetCategories_id($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetCategories_id($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetVideoDownloadedLink($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetVideoDownloadedLink($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetVideoGroups($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetVideoGroups($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetTrailer1($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetTrailer1($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetTrailer2($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetTrailer2($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetTrailer3($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetTrailer3($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetRate($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetRate($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetYoutubeId($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetYoutubeId($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetTitle($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetTitle($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetFilename($video_id, $oldValue, $newValue, $force) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetFilename($video_id, $oldValue, $newValue, $force); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetNext_videos_id($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetNext_videos_id($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetVideoLink($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetVideoLink($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetCan_download($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetCan_download($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetCan_share($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetCan_share($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetOnly_for_paid($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetOnly_for_paid($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetRrating($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetRrating($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetExternalOptions($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetExternalOptions($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetVideoStartSeconds($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetVideoStartSeconds($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function onVideoSetSerie_playlists_id($video_id, $oldValue, $newValue) { $plugins = Plugin::getAllEnabled(); foreach ($plugins as $value) { self::YPTstart(); $p = static::loadPlugin($value['dirName']); if (is_object($p)) { $p->onVideoSetSerie_playlists_id($video_id, $oldValue, $newValue); } self::YPTend("{$value['dirName']}::" . __FUNCTION__); } return; } public static function getPluginsOnByDefault($getUUID = true) { if (empty($getUUID)) { return array( 'CustomizeUser', // CustomizeUser 'CustomizeAdvanced', // CustomizeAdvanced 'Layout', // Layout 'PlayerSkins', // PlayerSkins 'Permissions', // Permissions 'Scheduler', // Permissions ); } else { return array( '55a4fa56-8a30-48d4-a0fb-8aa6b3fuser3', // CustomizeUser '55a4fa56-8a30-48d4-a0fb-8aa6b3f69033', // CustomizeAdvanced 'layout84-8f5a-4d1b-b912-172c608bf9e3', // Layout 'e9a568e6-ef61-4dcc-aad0-0109e9be8e36', // PlayerSkins 'Permissions-5ee8405eaaa16', // Permissions 'Scheduler-5ee8405eaaa16', // Permissions ); } } public static function getPluginsNameOnByDefaultFromUUID($UUID) { $UUIDs = self::getPluginsOnByDefault(); $key = array_search($UUID, $UUIDs); if ($key === false) { return false; } $names = self::getPluginsOnByDefault(false); if (empty($names[$key])) { return false; } return $names[$key]; } public static function isPluginOnByDefault($UUID) { $UUIDs = self::getPluginsOnByDefault(); return in_array($UUID, $UUIDs); } static function fixName($name) { if ($name === 'Programs') { return 'PlayLists'; } return $name; } } class YouPHPTubePlugin extends AVideoPlugin { } diff --git a/plugin/Layout/Layout.php b/plugin/Layout/Layout.php index 620891170..dc73dc8fd 100644 --- a/plugin/Layout/Layout.php +++ b/plugin/Layout/Layout.php @@ -1,457 +1,463 @@ type = "textarea"; $o->value = $subject; $obj->colorsVariables = $o; $obj->showCustomCSS = true; * */ - $obj->showButtonNotification = false; + //$obj->showButtonNotification = false; + $obj->categoriesTopButtons = false; $o = new stdClass(); $o->type = array(0 => '-- ' . __("Random")) + self::getLoadersArray(); $o->value = 'avideo'; $obj->pageLoader = $o; return $obj; } static function getLoadersArray() { $files = Layout::getLoadersFiles(); $response = array(); foreach ($files as $key => $value) { $response[$value['name']] = ucfirst($value['name']); } return $response; } static function getLoadersFiles() { global $global; $files = _glob($global['systemRootPath'] . 'plugin/Layout/loaders/', '/.*html/'); $response = array(); foreach ($files as $key => $value) { $name = str_replace('.html', '', basename($value)); $response[$name] = array('path' => $value, 'name' => $name); } return $response; } static public function getLoader($file) { global $global; $files = self::getLoadersFiles(); $name = ''; if (!empty($file)) { foreach ($files as $key => $value) { if ($file == $value['name']) { $name = $value['name']; break; } } } if (empty($name)) { $rand_key = array_rand($files); $name = $files[$rand_key]['name']; } $content = file_get_contents($global['systemRootPath'] . 'plugin/Layout/loaders/' . $name . '.html'); return trim(preg_replace('/\s+/', ' ', str_replace('lds-', 'lds-' . uniqid(), $content))); } static function getLoaderDefault() { global $_getLoaderDefault; if (!isset($_getLoaderDefault)) { $obj = AVideoPlugin::getObjectData('Layout'); $loader = Layout::getLoader($obj->pageLoader->value); //$loader = Layout::getLoader('spinner'); $parts = explode('', $loader); if (preg_match('/style/', $parts[0])) { $parts[0] .= ''; } $_getLoaderDefault = array('css' => $parts[0], 'html' => $parts[1]); } return $_getLoaderDefault; } static function getBGAnimationFiles() { global $global; $files = _glob($global['systemRootPath'] . 'plugin/Layout/animatedBackGrounds/', '/.*php/'); $response = array(); foreach ($files as $key => $value) { $name = str_replace('.php', '', basename($value)); $response[$name] = array('path' => $value, 'name' => $name); } return $response; } static function includeBGAnimationFile($file) { if (empty($file)) { return false; } $files = self::getBGAnimationFiles(); if ($file == 1) { $f = $files[array_rand($files)]; echo ''; include $f['path']; } foreach ($files as $key => $value) { if ($file == $value['name']) { include $value['path']; break; } } return true; } public function getPluginMenu() { global $global; return ""; $filename = $global['systemRootPath'] . 'plugin/Customize/pluginMenu.html'; return file_get_contents($filename); } public function getHeadCode() { global $global; $loaderParts = self::getLoaderDefault(); echo $loaderParts['css']; echo ""; return false; } static function getIconsList() { global $global; include $global['systemRootPath'] . 'plugin/Layout/fontAwesomeFAB.php'; // Fetch variables scss file in variable $font_vars = file_get_contents($global['systemRootPath'] . 'view/css/fontawesome-free-5.5.0-web/scss/_variables.scss'); // Find the position of first $fa-var , as all icon class names start after that $pos = strpos($font_vars, '$fa-var'); // Filter the string and return only the icon class names $font_vars = substr($font_vars, $pos); // Create an array of lines $lines = explode("\n", $font_vars); $fonts_list = array(); foreach ($lines as $line) { // Discard any black line or anything without : if (strpos($line, ':') !== false) { // Icon names and their Unicode Private Use Area values are separated with : and hence, explode them. $t = explode(":", $line); // Remove the $fa-var with fa, to use as css class names. $className = str_replace('$fa-var-', '', $t[0]); if (!in_array($className, $font_awesome_brands)) { $classNameFull = "fa fa-{$className}"; } else { $classNameFull = "fab fa-{$className}"; } $fonts_list[$className] = array($className, $classNameFull, $t[1]); } } return $fonts_list; } static function getSelectSearchable($optionsArray, $name, $selected, $id = "", $class = "", $placeholder = false, $templatePlaceholder='') { global $global; $html = ""; if (empty($global['getSelectSearchable'])) { $html .= ''; $html .= ''; } if (empty($class)) { $class = "js-select-search"; } $html .= ''; // this is just to display something before load the select2 if(empty($templatePlaceholder)){ $html .= ''; }else{ $html .= $templatePlaceholder; } $html .= ''; $global['getSelectSearchable'] = 1; return $html; } static function getIconsSelect($name, $selected = "", $id = "", $class = "") { global $getIconsSelect; $getIconsSelect = 1; $icons = self::getIconsList(); if (empty($id)) { $id = uniqid(); } $code = ""; self::addFooterCode($code); $code = ''; self::addFooterCode($code); return self::getSelectSearchable($icons, $name, $selected, $id, $class . " iconSelect", true); } static function getAvilableFlags() { global $global; $flags = array(); include_once $global['systemRootPath'].'objects/bcp47.php'; $files = _glob("{$global['systemRootPath']}locale", '/^[a-z]{2}(_.*)?.php$/'); foreach ($files as $filename) { $filename = basename($filename); $fileEx = basename($filename, ".php"); $name = $global['bcp47'][$fileEx]['label']; $flag = $global['bcp47'][$fileEx]['flag']; $flags[$fileEx] = array(json_encode(array('text'=>$name, 'icon'=>"flagstrap-icon flagstrap-{$flag}")), $fileEx, 'val3-'.$name); } return $flags; } static function getAllFlags() { global $global; $flags = array(); include_once $global['systemRootPath'].'objects/bcp47.php'; foreach ($global['bcp47'] as $key => $filename) { $name = $filename['label']; $flag = $filename['flag']; $flags[$key] = array(json_encode(array('text'=>$name, 'icon'=>"flagstrap-icon flagstrap-{$flag}")), $key, 'val3-'.$name); } return $flags; } static function getLangsSelect($name, $selected = "", $id = "", $class = "", $flagsOnly=false, $getAll=false) { global $getLangsSelect; $getLangsSelect = 1; if($getAll){ $flags = self::getAllFlags(); }else{ $flags = self::getAvilableFlags(); } if (empty($id)) { $id = uniqid(); } if($selected=='us'){ $selected = 'en_US'; } if(!empty($flags[$selected])){ $selectedJson = _json_decode($flags[$selected][0]); $selectedJsonIcon = $selectedJson->icon; }else{ $selectedJsonIcon = ''; } $code = ""; self::addFooterCode($code); if($flagsOnly){ $code = ''; }else{ $code = ''; } self::addFooterCode($code); $templatePlaceholder = '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . '' . ''; return self::getSelectSearchable($flags, $name, $selected, $id, $class . " flagSelect", true, $templatePlaceholder); } static function getCategorySelect($name, $selected = "", $id = "", $class = "") { $rows = Category::getAllCategories(true, false); array_multisort(array_column($rows, 'hierarchyAndName'), SORT_ASC, $rows); $cats = array(); foreach ($rows as $value) { $cats[$value['id']] = htmlentities(" " . $value['hierarchyAndName']); } if (empty($id)) { $id = uniqid(); } $methodName = __FUNCTION__; $code = "'; self::addFooterCode($code); return self::getSelectSearchable($cats, $name, $selected, $id, $class, true); } static function getUserGroupsSelect($name, $selected = "", $id = "", $class = "") { $rows = UserGroups::getAllUsersGroupsArray(); if (empty($id)) { $id = uniqid(); } $methodName = __FUNCTION__; $code = "'; self::addFooterCode($code); return self::getSelectSearchable($rows, $name, $selected, $id, $class, true); } public function getFooterCode() { global $global; $obj = $this->getDataObject(); $content = ''; if (!empty($global['getSelectSearchable'])) { $content .= ''; // $content .= ''; } $content .= self::_getFooterCode(); return $content; } private static function addFooterCode($code) { global $LayoutaddFooterCode; if (!isset($LayoutaddFooterCode)) { $LayoutaddFooterCode = array(); } $LayoutaddFooterCode[] = $code; } private static function _getFooterCode() { global $LayoutaddFooterCode; if (!isset($LayoutaddFooterCode)) { return ""; } $LayoutaddFooterCode = array_unique($LayoutaddFooterCode); return implode(PHP_EOL, $LayoutaddFooterCode); } public function getHTMLMenuRight() { global $global; $obj = $this->getDataObject(); if (empty($obj->showButtonNotification)) { return false; } include $global['systemRootPath'] . 'plugin/Layout/menuRight.php'; } + + public function navBarAfter() { + global $global; + include $global['systemRootPath'] . 'plugin/Layout/categoriesTopButtons.php'; + } } diff --git a/plugin/Layout/categoriesTopButtons.php b/plugin/Layout/categoriesTopButtons.php new file mode 100644 index 000000000..7bded4923 --- /dev/null +++ b/plugin/Layout/categoriesTopButtons.php @@ -0,0 +1,65 @@ + + +
    + +
    + \ No newline at end of file diff --git a/plugin/Plugin.abstract.php b/plugin/Plugin.abstract.php index 94e74791d..4d89e7b40 100644 --- a/plugin/Plugin.abstract.php +++ b/plugin/Plugin.abstract.php @@ -1,718 +1,722 @@ getUUID(); if (empty(PluginAbstract::$dataObject[$uuid])) { $obj = Plugin::getPluginByUUID($uuid); //echo $obj['object_data']; $o = array(); if (!empty($obj['object_data'])) { $o = _json_decode(stripslashes($obj['object_data'])); $json_last_error = json_last_error(); if ($json_last_error !== JSON_ERROR_NONE) { //var_dump($this->getName(), $json_last_error, $o, $obj['object_data']); //_error_log('getDataObject - JSON error (' . $json_last_error . ') ' . $this->getName()." ".$this->getUUID()); $o = _json_decode($obj['object_data']); $json_last_error = json_last_error(); } switch ($json_last_error) { case JSON_ERROR_NONE: //echo ' - No errors'; break; default: _error_log('getDataObject - JSON error ' . $this->getName()); _error_log($obj['object_data']); _error_log('striped slashes'); _error_log(stripslashes($obj['object_data'])); case JSON_ERROR_DEPTH: _error_log(' - Maximum stack depth exceeded'); break; case JSON_ERROR_STATE_MISMATCH: _error_log(' - Underflow or the modes mismatch'); break; case JSON_ERROR_CTRL_CHAR: _error_log(' - Unexpected control character found'); break; case JSON_ERROR_SYNTAX: _error_log(' - Syntax error, malformed JSON'); _error_log($obj['object_data']); _error_log('striped slashes'); _error_log(stripslashes($obj['object_data'])); break; case JSON_ERROR_UTF8: _error_log(' - Malformed UTF-8 characters, possibly incorrectly encoded'); break; } } $eo = $this->getEmptyDataObject(); // check if the plugin define any array for the select option, if does, overwrite it foreach ($eo as $key => $value) { if(isset($value->type) && is_array($value->type) && isset($o->$key) && isset($o->$key->type)){ $o->$key->type = $value->type; } } $wholeObjects = array_merge((array) $eo, (array) $o); $disabledPlugins = plugin::getAllDisabled(); foreach ($disabledPlugins as $value) { $p = AVideoPlugin::loadPlugin($value['dirName']); if (is_object($p)) { $foreginObjects = $p->getCustomizeAdvancedOptions(); if ($foreginObjects) { foreach ($foreginObjects as $optionName => $defaultValue) if (isset($wholeObjects[$optionName])) unset($wholeObjects[$optionName]); } } } PluginAbstract::$dataObject[$this->getUUID()] = $wholeObjects; }else { $wholeObjects = PluginAbstract::$dataObject[$this->getUUID()]; } //var_dump($obj['object_data']); //var_dump($eo, $o, (object) array_merge((array) $eo, (array) $o));exit; return (object) $wholeObjects; } public function setDataObject($object) { $pluginRow = Plugin::getPluginByUUID($this->getUUID()); if(empty($pluginRow)){ return false; } $obj = new Plugin($pluginRow['id']); $obj->setObject_data(addcslashes(json_encode($object), '\\')); return $obj->save(); } public function setDataObjectParameter($parameterName, $value) { $object = $this->getDataObject(); eval("\$object->$parameterName = \$value;"); return $this->setDataObject($object); } public function getEmptyDataObject() { $obj = new stdClass(); return $obj; } public function getFirstPage() { return false; } public function afterNewVideo($videos_id) { return false; } public function afterDonation($from_users_id, $how_much, $videos_id, $users_id) { return false; } public function afterNewComment($comments_id) { return false; } public function afterNewResponse($comments_id) { return false; } public function xsendfilePreVideoPlay() { return false; } public function getLogin() { $obj = new stdClass(); $obj->class = ""; // btn btn-primary btn-block $obj->icon = ""; // fab fa-facebook-square $obj->type = ""; // Facebook, Google, etc $obj->linkToDevelopersPage = ""; //https://console.developers.google.com/apis/credentials , https://developers.facebook.com/apps return $obj; } public function getWatchActionButton($videos_id) { return ""; } public function getNetflixActionButton($videos_id) { return ""; } public function getGalleryActionButton($videos_id) { return ""; } public function getStart() { return false; } public function getEnd() { return false; } public function afterVideoJS() { return false; } public function canEditPlugin() { global $global; return empty($global['disableAdvancedConfigurations']); } public function hidePlugin() { return false; } public function getChannelButton() { return ""; } public function getVideoManagerButton() { return ""; } public function getLivePanel() { return ""; } public function getPlayListButtons($playlist_id) { return ""; } public function getMyAccount($users_id) { return ""; } /** * * @return type array(array("key"=>'live key', "users"=>false, "name"=>$userName, "user"=>$user, "photo"=>$photo, "UserPhoto"=>$UserPhoto, "title"=>'')); */ public function getLiveApplicationArray() { return array(); } public function addRoutes() { return false; } public function addView($videos_id, $total) { return false; } public function getCustomizeAdvancedOptions() { return false; } public function getUserOptions() { return array(); } public function getModeYouTube($videos_id) { return false; } public function getModeLive($key) { return false; } public function getModeLiveLink($liveLink_id) { return false; } public function getModeYouTubeLive($users_id) { return false; } public function getEmbed($videos_id) { return false; } /** * Loads a channel before display the channel page, usefull to create customized channel pages * @param type $user is an database array from channels owner * @return boolean */ public function getChannel($user_id, $user) { return false; } /** * * @return type return a list of IDs of the user groups */ public function getDynamicUserGroupsId($users_id) { return array(); } public function getDynamicUsersId($users_groups_id) { return array(); } public function navBarButtons() { return ""; } public function navBarProfileButtons() { return ""; } public function navBar() { return ""; } + + public function navBarAfter() { + return ""; + } public function isReady($pluginsList) { $return = array('ready' => array(), 'missing' => array()); foreach ($pluginsList as $name) { $plugin = AVideoPlugin::loadPlugin($name); $uuid = $plugin->getUUID(); if (!AVideoPlugin::isEnabled($uuid)) { $return['missing'][] = array('name' => $name, 'uuid' => $uuid); } else { $return['ready'][] = array('name' => $name, 'uuid' => $uuid); } } return $return; } public function isReadyLabel($pluginsList) { $desc = "
    "; $ready = $this->isReady($pluginsList); foreach ($ready['ready'] as $value) { $desc .= "{$value['name']} "; } foreach ($ready['missing'] as $value) { $desc .= "{$value['name']} "; } return $desc; } public function getAllVideosExcludeVideosIDArray() { return array(); } /** * * @param type $users_id * @return 0 = I dont know, -1 = can not upload, 1 = can upload */ public function userCanUpload($users_id) { return 0; } /** * * @param type $users_id * @param type $videos_id * @return 0 = I dont know, -1 = can not watch, 1 = can watch */ public function userCanWatchVideo($users_id, $videos_id) { return 0; } /** * * @param type $users_id * @param type $videos_id * @return 0 = I dont know, -1 = can not watch, 1 = can watch */ public function userCanWatchVideoWithAds($users_id, $videos_id) { return 0; } /** * temporary, to avoid error on old secureVideosDirectory plugins * @return boolean */ function verifyEmbedSecurity() { return true; } function showAds($videos_id) { return true; } function isPaidUser($users_id) { return false; } function getVideo() { return null; } public function onUserSignIn($users_id) { return null; } public function onUserSignup($users_id) { return null; } public function onLiveStream($users_id, $live_servers_id) { return null; } public function thumbsOverlay($videos_id) { return ""; } public static function profileTabName($users_id) { return ""; } public static function profileTabContent($users_id) { return ""; } public static function getVideoWhereClause() { return ""; } public static function getManagerVideosAddNew() { return ""; } public static function saveVideosAddNew($post, $videos_id) { return true; } public static function getManagerVideosReset() { return ""; } public static function getManagerVideosEdit() { return ""; } public static function getManagerVideosEditField() { return ""; } public static function getManagerVideosJavaScripts() { return ""; } public static function getManagerVideosTab() { return ""; } public static function getManagerVideosBody() { return ""; } public static function getAllVideosArray($videos_id) { return array(); } public static function getVideoTags($videos_id) { return array(); } public function getMobileInfo() { return null; } public function getUploadMenuButton() { return ""; } public function dataSetup() { return ""; } function getPermissionsOptions(){ return array(); } protected function addDataObjectHelper($property, $name, $description=""){ $this->dataObjectHelper[$property] = array("name"=>$name, "description"=>$description); } function getDataObjectHelper(){ return $this->dataObjectHelper; } function onUserSocketConnect(){ } function onUserSocketDisconnect(){ } function onVideoSetLive_transmitions_history_id($video_id, $oldValue, $newValue) { } function onVideoSetEncoderURL($video_id, $oldValue, $newValue) { } function onVideoSetFilepath($video_id, $oldValue, $newValue) { } function onVideoSetFilesize($video_id, $oldValue, $newValue) { } function onVideoSetUsers_id($video_id, $oldValue, $newValue) { } function onVideoSetSites_id($video_id, $oldValue, $newValue) { } function onVideoSetVideo_password($video_id, $oldValue, $newValue) { } function onVideoSetClean_title($video_id, $oldValue, $newValue) { } function onVideoSetDuration($video_id, $oldValue, $newValue) { } function onVideoSetIsSuggested($video_id, $oldValue, $newValue) { } function onVideoSetStatus($video_id, $oldValue, $newValue) { } function onVideoSetType($video_id, $oldValue, $newValue, $force) { } function onVideoSetRotation($video_id, $oldValue, $newValue) { } function onVideoSetZoom($video_id, $oldValue, $newValue) { } function onVideoSetDescription($video_id, $oldValue, $newValue) { } function onVideoSetCategories_id($video_id, $oldValue, $newValue) { } function onVideoSetVideoDownloadedLink($video_id, $oldValue, $newValue) { } function onVideoSetVideoGroups($video_id, $oldValue, $newValue) { } function onVideoSetTrailer1($video_id, $oldValue, $newValue) { } function onVideoSetTrailer2($video_id, $oldValue, $newValue) { } function onVideoSetTrailer3($video_id, $oldValue, $newValue) { } function onVideoSetRate($video_id, $oldValue, $newValue) { } function onVideoSetYoutubeId($video_id, $oldValue, $newValue) { } function onVideoSetTitle($video_id, $oldValue, $newValue) { } function onVideoSetFilename($video_id, $oldValue, $newValue, $force) { } function onVideoSetNext_videos_id($video_id, $oldValue, $newValue) { } function onVideoSetVideoLink($video_id, $oldValue, $newValue) { } function onVideoSetCan_download($video_id, $oldValue, $newValue) { } function onVideoSetCan_share($video_id, $oldValue, $newValue) { } function onVideoSetOnly_for_paid($video_id, $oldValue, $newValue) { } function onVideoSetRrating($video_id, $oldValue, $newValue) { } function onVideoSetExternalOptions($video_id, $oldValue, $newValue) { } function onVideoSetVideoStartSeconds($video_id, $oldValue, $newValue) { } function onVideoSetSerie_playlists_id($video_id, $oldValue, $newValue) { } function updateParameter($parameterName, $newValue) { $pluginDO = $this->getDataObject(); $pluginDB = Plugin::getPluginByName($this->getName()); foreach ($pluginDO as $key => $value) { if ($key == $parameterName) { $pluginDO->$key = $newValue; } } $p = new Plugin($pluginDB['id']); $p->setObject_data(json_encode($pluginDO)); return $p->save(); } } class PluginPermissionOption{ private $type, $name, $description, $className; function __construct($type, $name, $description, $className) { $this->type = $type; $this->name = $name; $this->description = $description; $this->className = $className; } function getType() { return $this->type; } function getName() { return $this->name; } function getDescription() { return $this->description; } function getClassName() { return $this->className; } } diff --git a/view/bootstrap/jquery-bootstrap-scrolling-tabs/jquery.scrolling-tabs.css b/view/bootstrap/jquery-bootstrap-scrolling-tabs/jquery.scrolling-tabs.css new file mode 100644 index 000000000..f0617efc0 --- /dev/null +++ b/view/bootstrap/jquery-bootstrap-scrolling-tabs/jquery.scrolling-tabs.css @@ -0,0 +1,65 @@ +/** + * jquery-bootstrap-scrolling-tabs + * @version v2.6.1 + * @link https://github.com/mikejacobson/jquery-bootstrap-scrolling-tabs + * @author Mike Jacobson + * @license MIT License, http://www.opensource.org/licenses/MIT + */ +.scrtabs-tab-container * { + box-sizing: border-box; } + +.scrtabs-tab-container { + height: 42px; } + .scrtabs-tab-container .tab-content { + clear: left; } + +.scrtabs-tab-container.scrtabs-bootstrap4 .scrtabs-tabs-movable-container > .navbar-nav { + -ms-flex-direction: row; + flex-direction: row; } + +.scrtabs-tabs-fixed-container { + float: left; + height: 42px; + overflow: hidden; + width: 100%; } + +.scrtabs-tabs-movable-container { + position: relative; } + .scrtabs-tabs-movable-container .tab-content { + display: none; } + +.scrtabs-tab-container.scrtabs-rtl .scrtabs-tabs-movable-container > ul.nav-tabs { + padding-right: 0; } + +.scrtabs-tab-scroll-arrow { + border: 1px solid #dddddd; + border-top: none; + color: #428bca; + display: none; + float: left; + font-size: 12px; + height: 42px; + margin-bottom: -1px; + padding-left: 2px; + padding-top: 13px; + width: 20px; } + .scrtabs-tab-scroll-arrow:hover { + background-color: #eeeeee; } + +.scrtabs-tab-scroll-arrow, +.scrtabs-tab-scroll-arrow .scrtabs-click-target { + cursor: pointer; } + +.scrtabs-tab-scroll-arrow.scrtabs-with-click-target { + cursor: default; } + +.scrtabs-tab-scroll-arrow.scrtabs-disable, +.scrtabs-tab-scroll-arrow.scrtabs-disable .scrtabs-click-target { + color: #ddd; + cursor: default; } + +.scrtabs-tab-scroll-arrow.scrtabs-disable:hover { + background-color: initial; } + +.scrtabs-tabs-fixed-container ul.nav-tabs > li { + white-space: nowrap; } diff --git a/view/bootstrap/jquery-bootstrap-scrolling-tabs/jquery.scrolling-tabs.js b/view/bootstrap/jquery-bootstrap-scrolling-tabs/jquery.scrolling-tabs.js new file mode 100644 index 000000000..10887e421 --- /dev/null +++ b/view/bootstrap/jquery-bootstrap-scrolling-tabs/jquery.scrolling-tabs.js @@ -0,0 +1,2011 @@ +/** + * jquery-bootstrap-scrolling-tabs + * @version v2.6.1 + * @link https://github.com/mikejacobson/jquery-bootstrap-scrolling-tabs + * @author Mike Jacobson + * @license MIT License, http://www.opensource.org/licenses/MIT + */ +/** + * jQuery plugin version of Angular directive angular-bootstrap-scrolling-tabs: + * https://github.com/mikejacobson/angular-bootstrap-scrolling-tabs + * + * Usage: + * + * Use case #1: HTML-defined tabs + * ------------------------------ + * Demo: http://plnkr.co/edit/thyD0grCxIjyU4PoTt4x?p=preview + * + * Sample HTML: + * + * + * + * + * + *
    + *
    Tab 1 content...
    + *
    Tab 2 content...
    + *
    Tab 3 content...
    + *
    Tab 4 content...
    + *
    + * + * + * JavaScript: + * + * $('.nav-tabs').scrollingTabs(); + * + * + * Use Case #2: Data-driven tabs + * ----------------------------- + * Demo: http://plnkr.co/edit/MWBjLnTvJeetjU3NEimg?p=preview + * + * Sample HTML: + * + * + *
    + * + * + * JavaScript: + * + * $('#tabs-inside-here').scrollingTabs({ + * tabs: tabs, // required + * propPaneId: 'paneId', // optional + * propTitle: 'title', // optional + * propActive: 'active', // optional + * propDisabled: 'disabled', // optional + * propContent: 'content', // optional + * ignoreTabPanes: false, // optional + * scrollToTabEdge: false, // optional + * disableScrollArrowsOnFullyScrolled: false, // optional + * reverseScroll: false // optional + * }); + * + * Settings/Options: + * + * tabs: tabs data array + * prop*: name of your tab object's property name that + * corresponds to that required tab property if + * your property name is different than the + * standard name (paneId, title, etc.) + * tabsLiContent: + * optional string array used to define custom HTML + * for each tab's
  • element. Each entry is an HTML + * string defining the tab
  • element for the + * corresponding tab in the tabs array. + * The default for a tab is: + * '
  • ' + * So, for example, if you had 3 tabs and you needed + * a custom 'tooltip' attribute on each one, your + * tabsLiContent array might look like this: + * [ + * '', + * '', + * '' + * ] + * This plunk demonstrates its usage (in conjunction + * with tabsPostProcessors): + * http://plnkr.co/edit/ugJLMk7lmDCuZQziQ0k0 + * tabsPostProcessors: + * optional array of functions, each one associated + * with an entry in the tabs array. When a tab element + * has been created, its associated post-processor + * function will be called with two arguments: the + * newly created $li and $a jQuery elements for that tab. + * This allows you to, for example, attach a custom + * event listener to each anchor tag. + * This plunk demonstrates its usage (in conjunction + * with tabsLiContent): + * http://plnkr.co/edit/ugJLMk7lmDCuZQziQ0k0 + * ignoreTabPanes: relevant for data-driven tabs only--set to true if + * you want the plugin to only touch the tabs + * and to not generate the tab pane elements + * that go in .tab-content. By default, the plugin + * will generate the tab panes based on the content + * property in your tab data, if a content property + * is present. + * scrollToTabEdge: set to true if you want to force full-width tabs + * to display at the left scroll arrow. i.e., if the + * scrolling stops with only half a tab showing, + * it will snap the tab to its edge so the full tab + * shows. + * disableScrollArrowsOnFullyScrolled: + * set to true if you want the left scroll arrow to + * disable when the tabs are scrolled fully left, + * and the right scroll arrow to disable when the tabs + * are scrolled fully right. + * reverseScroll: + * set to true if you want the left scroll arrow to + * slide the tabs left instead of right, and the right + * scroll arrow to slide the tabs right. + * enableSwiping: + * set to true if you want to enable horizontal swiping + * for touch screens. + * widthMultiplier: + * set to a value less than 1 if you want the tabs + * container to be less than the full width of its + * parent element. For example, set it to 0.5 if you + * want the tabs container to be half the width of + * its parent. + * tabClickHandler: + * a callback function to execute any time a tab is clicked. + * The function is simply passed as the event handler + * to jQuery's .on(), so the function will receive + * the jQuery event as an argument, and the 'this' + * inside the function will be the clicked tab's anchor + * element. + * cssClassLeftArrow, cssClassRightArrow: + * custom values for the class attributes for the + * left and right scroll arrows. The defaults are + * 'glyphicon glyphicon-chevron-left' and + * 'glyphicon glyphicon-chevron-right'. + * Using different icons might require you to add + * custom styling to the arrows to position the icons + * correctly; the arrows can be targeted with these + * selectors: + * .scrtabs-tab-scroll-arrow + * .scrtabs-tab-scroll-arrow-left + * .scrtabs-tab-scroll-arrow-right + * leftArrowContent, rightArrowContent: + * custom HTML string for the left and right scroll + * arrows. This will override any custom cssClassLeftArrow + * and cssClassRightArrow settings. + * For example, if you wanted to use svg icons, you + * could set them like so: + * + * leftArrowContent: [ + * '
    ', + * ' ', + * ' ', + * ' ', + * '
    ' + * ].join(''), + * rightArrowContent: [ + * '
    ', + * ' ', + * ' ', + * ' ', + * '
    ' + * ].join('') + * + * You would then need to add some CSS to make them + * work correctly if you don't give them the + * default scrtabs-tab-scroll-arrow classes. + * This plunk shows it working with svg icons: + * http://plnkr.co/edit/2MdZCAnLyeU40shxaol3?p=preview + * + * When using this option, you can also mark a child + * element within the arrow content as the click target + * if you don't want the entire content to be + * clickable. You do that my adding the CSS class + * 'scrtabs-click-target' to the element that should + * be clickable, like so: + * + * leftArrowContent: [ + * '
    ', + * ' ', + * '
    ' + * ].join(''), + * rightArrowContent: [ + * '
    ', + * ' ', + * '
    ' + * ].join('') + * + * enableRtlSupport: + * set to true if you want your site to support + * right-to-left languages. If true, the plugin will + * check the page's tag for attribute dir="rtl" + * and will adjust its behavior accordingly. + * handleDelayedScrollbar: + * set to true if you experience a situation where the + * right scroll arrow wraps to the next line due to a + * vertical scrollbar coming into existence on the page + * after the plugin already calculated its width without + * a scrollbar present. This would occur if, for example, + * the bulk of the page's content loaded after a delay, + * and only then did a vertical scrollbar become necessary. + * It would also occur if a vertical scrollbar only appeared + * on selection of a particular tab that had more content + * than the default tab. + * bootstrapVersion: + * set to 4 if you're using Boostrap 4. Default is 3. + * Bootstrap 4 handles some things differently than 3 + * (e.g., the 'active' class gets applied to the tab's + * 'li > a' element rather than the 'li' itself). + * + * + * On tabs data change: + * + * $('#tabs-inside-here').scrollingTabs('refresh'); + * + * On tabs data change, if you want the active tab to be set based on + * the updated tabs data (i.e., you want to override the current + * active tab setting selected by the user), for example, if you + * added a new tab and you want it to be the active tab: + * + * $('#tabs-inside-here').scrollingTabs('refresh', { + * forceActiveTab: true + * }); + * + * Any options that can be passed into the plugin can be set on the + * plugin's 'defaults' object instead so you don't have to pass them in: + * + * $.fn.scrollingTabs.defaults.tabs = tabs; + * $.fn.scrollingTabs.defaults.forceActiveTab = true; + * $.fn.scrollingTabs.defaults.scrollToTabEdge = true; + * $.fn.scrollingTabs.defaults.disableScrollArrowsOnFullyScrolled = true; + * $.fn.scrollingTabs.defaults.reverseScroll = true; + * $.fn.scrollingTabs.defaults.widthMultiplier = 0.5; + * $.fn.scrollingTabs.defaults.tabClickHandler = function () { }; + * + * + * Methods + * ----------------------------- + * - refresh + * On window resize, the tabs should refresh themselves, but to force a refresh: + * + * $('.nav-tabs').scrollingTabs('refresh'); + * + * - scrollToActiveTab + * On window resize, the active tab will automatically be scrolled to + * if it ends up offscreen, but you can also programmatically force a + * scroll to the active tab any time (if, for example, you're + * programmatically setting the active tab) by calling the + * 'scrollToActiveTab' method: + * + * $('.nav-tabs').scrollingTabs('scrollToActiveTab'); + * + * + * Events + * ----------------------------- + * The plugin triggers event 'ready.scrtabs' when the tabs have + * been wrapped in the scroller and are ready for viewing: + * + * $('.nav-tabs') + * .scrollingTabs() + * .on('ready.scrtabs', function() { + * // tabs ready, do my other stuff... + * }); + * + * $('#tabs-inside-here') + * .scrollingTabs({ tabs: tabs }) + * .on('ready.scrtabs', function() { + * // tabs ready, do my other stuff... + * }); + * + * + * Destroying + * ----------------------------- + * To destroy: + * + * $('.nav-tabs').scrollingTabs('destroy'); + * + * $('#tabs-inside-here').scrollingTabs('destroy'); + * + * If you were wrapping markup, the markup will be restored; if your tabs + * were data-driven, the tabs will be destroyed along with the plugin. + * + */ + +;(function ($, window) { + 'use strict'; + /* jshint unused:false */ + + /* exported CONSTANTS */ + var CONSTANTS = { + CONTINUOUS_SCROLLING_TIMEOUT_INTERVAL: 50, // timeout interval for repeatedly moving the tabs container + // by one increment while the mouse is held down--decrease to + // make mousedown continous scrolling faster + SCROLL_OFFSET_FRACTION: 6, // each click moves the container this fraction of the fixed container--decrease + // to make the tabs scroll farther per click + + DATA_KEY_DDMENU_MODIFIED: 'scrtabsddmenumodified', + DATA_KEY_IS_MOUSEDOWN: 'scrtabsismousedown', + DATA_KEY_BOOTSTRAP_TAB: 'bs.tab', + + CSS_CLASSES: { + BOOTSTRAP4: 'scrtabs-bootstrap4', + RTL: 'scrtabs-rtl', + SCROLL_ARROW_CLICK_TARGET: 'scrtabs-click-target', + SCROLL_ARROW_DISABLE: 'scrtabs-disable', + SCROLL_ARROW_WITH_CLICK_TARGET: 'scrtabs-with-click-target' + }, + + SLIDE_DIRECTION: { + LEFT: 1, + RIGHT: 2 + }, + + EVENTS: { + CLICK: 'click.scrtabs', + DROPDOWN_MENU_HIDE: 'hide.bs.dropdown.scrtabs', + DROPDOWN_MENU_SHOW: 'show.bs.dropdown.scrtabs', + FORCE_REFRESH: 'forcerefresh.scrtabs', + MOUSEDOWN: 'mousedown.scrtabs', + MOUSEUP: 'mouseup.scrtabs', + TABS_READY: 'ready.scrtabs', + TOUCH_END: 'touchend.scrtabs', + TOUCH_MOVE: 'touchmove.scrtabs', + TOUCH_START: 'touchstart.scrtabs', + WINDOW_RESIZE: 'resize.scrtabs' + } + }; + + // smartresize from Paul Irish (debounced window resize) + (function (sr) { + var debounce = function (func, threshold, execAsap) { + var timeout; + + return function debounced() { + var obj = this, args = arguments; + function delayed() { + if (!execAsap) { + func.apply(obj, args); + } + timeout = null; + } + + if (timeout) { + clearTimeout(timeout); + } else if (execAsap) { + func.apply(obj, args); + } + + timeout = setTimeout(delayed, threshold || 100); + }; + }; + $.fn[sr] = function (fn, customEventName) { + var eventName = customEventName || CONSTANTS.EVENTS.WINDOW_RESIZE; + return fn ? this.bind(eventName, debounce(fn)) : this.trigger(sr); + }; + + })('smartresizeScrtabs'); + + /* *********************************************************************************** + * ElementsHandler - Class that each instance of ScrollingTabsControl will instantiate + * **********************************************************************************/ + function ElementsHandler(scrollingTabsControl) { + var ehd = this; + + ehd.stc = scrollingTabsControl; + } + + // ElementsHandler prototype methods + (function (p) { + p.initElements = function (options) { + var ehd = this; + + ehd.setElementReferences(options); + ehd.setEventListeners(options); + }; + + p.listenForTouchEvents = function () { + var ehd = this, + stc = ehd.stc, + smv = stc.scrollMovement, + ev = CONSTANTS.EVENTS; + + var touching = false; + var touchStartX; + var startingContainerLeftPos; + var newLeftPos; + + stc.$movableContainer + .on(ev.TOUCH_START, function (e) { + touching = true; + startingContainerLeftPos = stc.movableContainerLeftPos; + touchStartX = e.originalEvent.changedTouches[0].pageX; + }) + .on(ev.TOUCH_END, function () { + touching = false; + }) + .on(ev.TOUCH_MOVE, function (e) { + if (!touching) { + return; + } + + var touchPageX = e.originalEvent.changedTouches[0].pageX; + var diff = touchPageX - touchStartX; + if (stc.rtl) { + diff = -diff; + } + var minPos; + + newLeftPos = startingContainerLeftPos + diff; + if (newLeftPos > 0) { + newLeftPos = 0; + } else { + minPos = smv.getMinPos(); + if (newLeftPos < minPos) { + newLeftPos = minPos; + } + } + stc.movableContainerLeftPos = newLeftPos; + + var leftOrRight = stc.rtl ? 'right' : 'left'; + stc.$movableContainer.css(leftOrRight, smv.getMovableContainerCssLeftVal()); + smv.refreshScrollArrowsDisabledState(); + }); + }; + + p.refreshAllElementSizes = function () { + var ehd = this, + stc = ehd.stc, + smv = stc.scrollMovement, + scrollArrowsWereVisible = stc.scrollArrowsVisible, + actionsTaken = { + didScrollToActiveTab: false + }, + isPerformingSlideAnim = false, + minPos; + + ehd.setElementWidths(); + ehd.setScrollArrowVisibility(); + + // this could have been a window resize or the removal of a + // dynamic tab, so make sure the movable container is positioned + // correctly because, if it is far to the left and we increased the + // window width, it's possible that the tabs will be too far left, + // beyond the min pos. + if (stc.scrollArrowsVisible) { + // make sure container not too far left + minPos = smv.getMinPos(); + + isPerformingSlideAnim = smv.scrollToActiveTab({ + isOnWindowResize: true + }); + + if (!isPerformingSlideAnim) { + smv.refreshScrollArrowsDisabledState(); + + if (stc.rtl) { + if (stc.movableContainerRightPos < minPos) { + smv.incrementMovableContainerLeft(minPos); + } + } else { + if (stc.movableContainerLeftPos < minPos) { + smv.incrementMovableContainerRight(minPos); + } + } + } + + actionsTaken.didScrollToActiveTab = true; + + } else if (scrollArrowsWereVisible) { + // scroll arrows went away after resize, so position movable container at 0 + stc.movableContainerLeftPos = 0; + smv.slideMovableContainerToLeftPos(); + } + + return actionsTaken; + }; + + p.setElementReferences = function (settings) { + var ehd = this, + stc = ehd.stc, + $tabsContainer = stc.$tabsContainer, + $leftArrow, + $rightArrow, + $leftArrowClickTarget, + $rightArrowClickTarget; + + stc.isNavPills = false; + + if (stc.rtl) { + $tabsContainer.addClass(CONSTANTS.CSS_CLASSES.RTL); + } + + if (stc.usingBootstrap4) { + $tabsContainer.addClass(CONSTANTS.CSS_CLASSES.BOOTSTRAP4); + } + + stc.$fixedContainer = $tabsContainer.find('.scrtabs-tabs-fixed-container'); + $leftArrow = stc.$fixedContainer.prev(); + $rightArrow = stc.$fixedContainer.next(); + + // if we have custom arrow content, we might have a click target defined + if (settings.leftArrowContent) { + $leftArrowClickTarget = $leftArrow.find('.' + CONSTANTS.CSS_CLASSES.SCROLL_ARROW_CLICK_TARGET); + } + + if (settings.rightArrowContent) { + $rightArrowClickTarget = $rightArrow.find('.' + CONSTANTS.CSS_CLASSES.SCROLL_ARROW_CLICK_TARGET); + } + + if ($leftArrowClickTarget && $leftArrowClickTarget.length) { + $leftArrow.addClass(CONSTANTS.CSS_CLASSES.SCROLL_ARROW_WITH_CLICK_TARGET); + } else { + $leftArrowClickTarget = $leftArrow; + } + + if ($rightArrowClickTarget && $rightArrowClickTarget.length) { + $rightArrow.addClass(CONSTANTS.CSS_CLASSES.SCROLL_ARROW_WITH_CLICK_TARGET); + } else { + $rightArrowClickTarget = $rightArrow; + } + + stc.$movableContainer = $tabsContainer.find('.scrtabs-tabs-movable-container'); + stc.$tabsUl = $tabsContainer.find('.nav-tabs'); + + // check for pills + if (!stc.$tabsUl.length) { + stc.$tabsUl = $tabsContainer.find('.nav-pills'); + + if (stc.$tabsUl.length) { + stc.isNavPills = true; + } + } + + stc.$tabsLiCollection = stc.$tabsUl.find('> li'); + + stc.$slideLeftArrow = stc.reverseScroll ? $leftArrow : $rightArrow; + stc.$slideLeftArrowClickTarget = stc.reverseScroll ? $leftArrowClickTarget : $rightArrowClickTarget; + stc.$slideRightArrow = stc.reverseScroll ? $rightArrow : $leftArrow; + stc.$slideRightArrowClickTarget = stc.reverseScroll ? $rightArrowClickTarget : $leftArrowClickTarget; + stc.$scrollArrows = stc.$slideLeftArrow.add(stc.$slideRightArrow); + + stc.$win = $(window); + }; + + p.setElementWidths = function () { + var ehd = this, + stc = ehd.stc; + + stc.winWidth = stc.$win.width(); + stc.scrollArrowsCombinedWidth = stc.$slideLeftArrow.outerWidth() + stc.$slideRightArrow.outerWidth(); + + ehd.setFixedContainerWidth(); + ehd.setMovableContainerWidth(); + }; + + p.setEventListeners = function (settings) { + var ehd = this, + stc = ehd.stc, + evh = stc.eventHandlers, + ev = CONSTANTS.EVENTS, + resizeEventName = ev.WINDOW_RESIZE + stc.instanceId; + + if (settings.enableSwiping) { + ehd.listenForTouchEvents(); + } + + stc.$slideLeftArrowClickTarget + .off('.scrtabs') + .on(ev.MOUSEDOWN, function (e) { evh.handleMousedownOnSlideMovContainerLeftArrow.call(evh, e); }) + .on(ev.MOUSEUP, function (e) { evh.handleMouseupOnSlideMovContainerLeftArrow.call(evh, e); }) + .on(ev.CLICK, function (e) { evh.handleClickOnSlideMovContainerLeftArrow.call(evh, e); }); + + stc.$slideRightArrowClickTarget + .off('.scrtabs') + .on(ev.MOUSEDOWN, function (e) { evh.handleMousedownOnSlideMovContainerRightArrow.call(evh, e); }) + .on(ev.MOUSEUP, function (e) { evh.handleMouseupOnSlideMovContainerRightArrow.call(evh, e); }) + .on(ev.CLICK, function (e) { evh.handleClickOnSlideMovContainerRightArrow.call(evh, e); }); + + if (stc.tabClickHandler) { + stc.$tabsLiCollection + .find('a[data-toggle="tab"]') + .off(ev.CLICK) + .on(ev.CLICK, stc.tabClickHandler); + } + + if (settings.handleDelayedScrollbar) { + ehd.listenForDelayedScrollbar(); + } + + stc.$win + .off(resizeEventName) + .smartresizeScrtabs(function (e) { evh.handleWindowResize.call(evh, e); }, resizeEventName); + + $('body').on(CONSTANTS.EVENTS.FORCE_REFRESH, stc.elementsHandler.refreshAllElementSizes.bind(stc.elementsHandler)); + }; + + p.listenForDelayedScrollbar = function () { + var iframe = document.createElement('iframe'); + iframe.id = "scrtabs-scrollbar-resize-listener"; + iframe.style.cssText = 'height: 0; background-color: transparent; margin: 0; padding: 0; overflow: hidden; border-width: 0; position: absolute; width: 100%;'; + iframe.onload = function() { + var timeout; + + function handleResize() { + try { + $(window).trigger('resize'); + timeout = null; + } catch(e) {} + } + + iframe.contentWindow.addEventListener('resize', function() { + if (timeout) { + clearTimeout(timeout); + } + + timeout = setTimeout(handleResize, 100); + }); + }; + + document.body.appendChild(iframe); + }; + + p.setFixedContainerWidth = function () { + var ehd = this, + stc = ehd.stc, + tabsContainerRect = stc.$tabsContainer.get(0).getBoundingClientRect(); + /** + * @author poletaew + * It solves problem with rounding by jQuery.outerWidth + * If we have real width 100.5 px, jQuery.outerWidth returns us 101 px and we get layout's fail + */ + stc.fixedContainerWidth = tabsContainerRect.width || (tabsContainerRect.right - tabsContainerRect.left); + stc.fixedContainerWidth = stc.fixedContainerWidth * stc.widthMultiplier; + + stc.$fixedContainer.width(stc.fixedContainerWidth); + }; + + p.setFixedContainerWidthForHiddenScrollArrows = function () { + var ehd = this, + stc = ehd.stc; + + stc.$fixedContainer.width(stc.fixedContainerWidth); + }; + + p.setFixedContainerWidthForVisibleScrollArrows = function () { + var ehd = this, + stc = ehd.stc; + + stc.$fixedContainer.width(stc.fixedContainerWidth - stc.scrollArrowsCombinedWidth); + }; + + p.setMovableContainerWidth = function () { + var ehd = this, + stc = ehd.stc, + $tabLi = stc.$tabsUl.find('> li'); + + stc.movableContainerWidth = 0; + + if ($tabLi.length) { + + $tabLi.each(function () { + var $li = $(this), + totalMargin = 0; + + if (stc.isNavPills) { // pills have a margin-left, tabs have no margin + totalMargin = parseInt($li.css('margin-left'), 10) + parseInt($li.css('margin-right'), 10); + } + + stc.movableContainerWidth += ($li.outerWidth() + totalMargin); + }); + + stc.movableContainerWidth += 1; + + // if the tabs don't span the width of the page, force the + // movable container width to full page width so the bottom + // border spans the page width instead of just spanning the + // width of the tabs + if (stc.movableContainerWidth < stc.fixedContainerWidth) { + stc.movableContainerWidth = stc.fixedContainerWidth; + } + } + + stc.$movableContainer.width(stc.movableContainerWidth); + }; + + p.setScrollArrowVisibility = function () { + var ehd = this, + stc = ehd.stc, + shouldBeVisible = stc.movableContainerWidth > stc.fixedContainerWidth; + + if (shouldBeVisible && !stc.scrollArrowsVisible) { + stc.$scrollArrows.show(); + stc.scrollArrowsVisible = true; + } else if (!shouldBeVisible && stc.scrollArrowsVisible) { + stc.$scrollArrows.hide(); + stc.scrollArrowsVisible = false; + } + + if (stc.scrollArrowsVisible) { + ehd.setFixedContainerWidthForVisibleScrollArrows(); + } else { + ehd.setFixedContainerWidthForHiddenScrollArrows(); + } + }; + + }(ElementsHandler.prototype)); + + /* *********************************************************************************** + * EventHandlers - Class that each instance of ScrollingTabsControl will instantiate + * **********************************************************************************/ + function EventHandlers(scrollingTabsControl) { + var evh = this; + + evh.stc = scrollingTabsControl; + } + + // prototype methods + (function (p){ + p.handleClickOnSlideMovContainerLeftArrow = function () { + var evh = this, + stc = evh.stc; + + stc.scrollMovement.incrementMovableContainerLeft(); + }; + + p.handleClickOnSlideMovContainerRightArrow = function () { + var evh = this, + stc = evh.stc; + + stc.scrollMovement.incrementMovableContainerRight(); + }; + + p.handleMousedownOnSlideMovContainerLeftArrow = function () { + var evh = this, + stc = evh.stc; + + stc.$slideLeftArrowClickTarget.data(CONSTANTS.DATA_KEY_IS_MOUSEDOWN, true); + stc.scrollMovement.continueSlideMovableContainerLeft(); + }; + + p.handleMousedownOnSlideMovContainerRightArrow = function () { + var evh = this, + stc = evh.stc; + + stc.$slideRightArrowClickTarget.data(CONSTANTS.DATA_KEY_IS_MOUSEDOWN, true); + stc.scrollMovement.continueSlideMovableContainerRight(); + }; + + p.handleMouseupOnSlideMovContainerLeftArrow = function () { + var evh = this, + stc = evh.stc; + + stc.$slideLeftArrowClickTarget.data(CONSTANTS.DATA_KEY_IS_MOUSEDOWN, false); + }; + + p.handleMouseupOnSlideMovContainerRightArrow = function () { + var evh = this, + stc = evh.stc; + + stc.$slideRightArrowClickTarget.data(CONSTANTS.DATA_KEY_IS_MOUSEDOWN, false); + }; + + p.handleWindowResize = function () { + var evh = this, + stc = evh.stc, + newWinWidth = stc.$win.width(); + + if (newWinWidth === stc.winWidth) { + return false; + } + + stc.winWidth = newWinWidth; + stc.elementsHandler.refreshAllElementSizes(); + }; + + }(EventHandlers.prototype)); + + /* *********************************************************************************** + * ScrollMovement - Class that each instance of ScrollingTabsControl will instantiate + * **********************************************************************************/ + function ScrollMovement(scrollingTabsControl) { + var smv = this; + + smv.stc = scrollingTabsControl; + } + + // prototype methods + (function (p) { + + p.continueSlideMovableContainerLeft = function () { + var smv = this, + stc = smv.stc; + + setTimeout(function() { + if (stc.movableContainerLeftPos <= smv.getMinPos() || + !stc.$slideLeftArrowClickTarget.data(CONSTANTS.DATA_KEY_IS_MOUSEDOWN)) { + return; + } + + if (!smv.incrementMovableContainerLeft()) { // haven't reached max left + smv.continueSlideMovableContainerLeft(); + } + }, CONSTANTS.CONTINUOUS_SCROLLING_TIMEOUT_INTERVAL); + }; + + p.continueSlideMovableContainerRight = function () { + var smv = this, + stc = smv.stc; + + setTimeout(function() { + if (stc.movableContainerLeftPos >= 0 || + !stc.$slideRightArrowClickTarget.data(CONSTANTS.DATA_KEY_IS_MOUSEDOWN)) { + return; + } + + if (!smv.incrementMovableContainerRight()) { // haven't reached max right + smv.continueSlideMovableContainerRight(); + } + }, CONSTANTS.CONTINUOUS_SCROLLING_TIMEOUT_INTERVAL); + }; + + p.decrementMovableContainerLeftPos = function (minPos) { + var smv = this, + stc = smv.stc; + + stc.movableContainerLeftPos -= (stc.fixedContainerWidth / CONSTANTS.SCROLL_OFFSET_FRACTION); + if (stc.movableContainerLeftPos < minPos) { + stc.movableContainerLeftPos = minPos; + } else if (stc.scrollToTabEdge) { + smv.setMovableContainerLeftPosToTabEdge(CONSTANTS.SLIDE_DIRECTION.LEFT); + + if (stc.movableContainerLeftPos < minPos) { + stc.movableContainerLeftPos = minPos; + } + } + }; + + p.disableSlideLeftArrow = function () { + var smv = this, + stc = smv.stc; + + if (!stc.disableScrollArrowsOnFullyScrolled || !stc.scrollArrowsVisible) { + return; + } + + stc.$slideLeftArrow.addClass(CONSTANTS.CSS_CLASSES.SCROLL_ARROW_DISABLE); + }; + + p.disableSlideRightArrow = function () { + var smv = this, + stc = smv.stc; + + if (!stc.disableScrollArrowsOnFullyScrolled || !stc.scrollArrowsVisible) { + return; + } + + stc.$slideRightArrow.addClass(CONSTANTS.CSS_CLASSES.SCROLL_ARROW_DISABLE); + }; + + p.enableSlideLeftArrow = function () { + var smv = this, + stc = smv.stc; + + if (!stc.disableScrollArrowsOnFullyScrolled || !stc.scrollArrowsVisible) { + return; + } + + stc.$slideLeftArrow.removeClass(CONSTANTS.CSS_CLASSES.SCROLL_ARROW_DISABLE); + }; + + p.enableSlideRightArrow = function () { + var smv = this, + stc = smv.stc; + + if (!stc.disableScrollArrowsOnFullyScrolled || !stc.scrollArrowsVisible) { + return; + } + + stc.$slideRightArrow.removeClass(CONSTANTS.CSS_CLASSES.SCROLL_ARROW_DISABLE); + }; + + p.getMinPos = function () { + var smv = this, + stc = smv.stc; + + return stc.scrollArrowsVisible ? (stc.fixedContainerWidth - stc.movableContainerWidth - stc.scrollArrowsCombinedWidth) : 0; + }; + + p.getMovableContainerCssLeftVal = function () { + var smv = this, + stc = smv.stc; + + return (stc.movableContainerLeftPos === 0) ? '0' : stc.movableContainerLeftPos + 'px'; + }; + + p.incrementMovableContainerLeft = function () { + var smv = this, + stc = smv.stc, + minPos = smv.getMinPos(); + + smv.decrementMovableContainerLeftPos(minPos); + smv.slideMovableContainerToLeftPos(); + smv.enableSlideRightArrow(); + + // return true if we're fully left, false otherwise + return (stc.movableContainerLeftPos === minPos); + }; + + p.incrementMovableContainerRight = function (minPos) { + var smv = this, + stc = smv.stc; + + // if minPos passed in, the movable container was beyond the minPos + if (minPos) { + stc.movableContainerLeftPos = minPos; + } else { + stc.movableContainerLeftPos += (stc.fixedContainerWidth / CONSTANTS.SCROLL_OFFSET_FRACTION); + + if (stc.movableContainerLeftPos > 0) { + stc.movableContainerLeftPos = 0; + } else if (stc.scrollToTabEdge) { + smv.setMovableContainerLeftPosToTabEdge(CONSTANTS.SLIDE_DIRECTION.RIGHT); + } + } + + smv.slideMovableContainerToLeftPos(); + smv.enableSlideLeftArrow(); + + // return true if we're fully right, false otherwise + // left pos of 0 is the movable container's max position (farthest right) + return (stc.movableContainerLeftPos === 0); + }; + + p.refreshScrollArrowsDisabledState = function() { + var smv = this, + stc = smv.stc; + + if (!stc.disableScrollArrowsOnFullyScrolled || !stc.scrollArrowsVisible) { + return; + } + + if (stc.movableContainerLeftPos >= 0) { // movable container fully right + smv.disableSlideRightArrow(); + smv.enableSlideLeftArrow(); + return; + } + + if (stc.movableContainerLeftPos <= smv.getMinPos()) { // fully left + smv.disableSlideLeftArrow(); + smv.enableSlideRightArrow(); + return; + } + + smv.enableSlideLeftArrow(); + smv.enableSlideRightArrow(); + }; + + p.scrollToActiveTab = function () { + var smv = this, + stc = smv.stc, + $activeTab, + $activeTabAnchor, + activeTabLeftPos, + activeTabRightPos, + rightArrowLeftPos, + activeTabWidth, + leftPosOffset, + offsetToMiddle, + leftScrollArrowWidth, + rightScrollArrowWidth; + + if (!stc.scrollArrowsVisible) { + return; + } + + if (stc.usingBootstrap4) { + $activeTabAnchor = stc.$tabsUl.find('li > .nav-link.active'); + if ($activeTabAnchor.length) { + $activeTab = $activeTabAnchor.parent(); + } + } else { + $activeTab = stc.$tabsUl.find('li.active'); + } + + if (!$activeTab || !$activeTab.length) { + return; + } + + rightScrollArrowWidth = stc.$slideRightArrow.outerWidth(); + activeTabWidth = $activeTab.outerWidth(); + + /** + * @author poletaew + * We need relative offset (depends on $fixedContainer), don't absolute + */ + activeTabLeftPos = $activeTab.offset().left - stc.$fixedContainer.offset().left; + activeTabRightPos = activeTabLeftPos + activeTabWidth; + + rightArrowLeftPos = stc.fixedContainerWidth - rightScrollArrowWidth; + + if (stc.rtl) { + leftScrollArrowWidth = stc.$slideLeftArrow.outerWidth(); + + if (activeTabLeftPos < 0) { // active tab off left side + stc.movableContainerLeftPos += activeTabLeftPos; + smv.slideMovableContainerToLeftPos(); + return true; + } else { // active tab off right side + if (activeTabRightPos > rightArrowLeftPos) { + stc.movableContainerLeftPos += (activeTabRightPos - rightArrowLeftPos) + (2 * rightScrollArrowWidth); + smv.slideMovableContainerToLeftPos(); + return true; + } + } + } else { + if (activeTabRightPos > rightArrowLeftPos) { // active tab off right side + leftPosOffset = activeTabRightPos - rightArrowLeftPos + rightScrollArrowWidth; + offsetToMiddle = stc.fixedContainerWidth / 2; + leftPosOffset += offsetToMiddle - (activeTabWidth / 2); + stc.movableContainerLeftPos -= leftPosOffset; + smv.slideMovableContainerToLeftPos(); + return true; + } else { + leftScrollArrowWidth = stc.$slideLeftArrow.outerWidth(); + if (activeTabLeftPos < 0) { // active tab off left side + offsetToMiddle = stc.fixedContainerWidth / 2; + stc.movableContainerLeftPos += (-activeTabLeftPos) + offsetToMiddle - (activeTabWidth / 2); + smv.slideMovableContainerToLeftPos(); + return true; + } + } + } + + return false; + }; + + p.setMovableContainerLeftPosToTabEdge = function (slideDirection) { + var smv = this, + stc = smv.stc, + offscreenWidth = -stc.movableContainerLeftPos, + totalTabWidth = 0; + + // make sure LeftPos is set so that a tab edge will be against the + // left scroll arrow so we won't have a partial, cut-off tab + stc.$tabsLiCollection.each(function () { + var tabWidth = $(this).width(); + + totalTabWidth += tabWidth; + + if (totalTabWidth > offscreenWidth) { + stc.movableContainerLeftPos = (slideDirection === CONSTANTS.SLIDE_DIRECTION.RIGHT) ? -(totalTabWidth - tabWidth) : -totalTabWidth; + return false; // exit .each() loop + } + + }); + }; + + p.slideMovableContainerToLeftPos = function () { + var smv = this, + stc = smv.stc, + minPos = smv.getMinPos(), + leftOrRightVal; + + if (stc.movableContainerLeftPos > 0) { + stc.movableContainerLeftPos = 0; + } else if (stc.movableContainerLeftPos < minPos) { + stc.movableContainerLeftPos = minPos; + } + + stc.movableContainerLeftPos = stc.movableContainerLeftPos / 1; + leftOrRightVal = smv.getMovableContainerCssLeftVal(); + + smv.performingSlideAnim = true; + + var targetPos = stc.rtl ? { right: leftOrRightVal } : { left: leftOrRightVal }; + + stc.$movableContainer.stop().animate(targetPos, 'slow', function __slideAnimComplete() { + var newMinPos = smv.getMinPos(); + + smv.performingSlideAnim = false; + + // if we slid past the min pos--which can happen if you resize the window + // quickly--move back into position + if (stc.movableContainerLeftPos < newMinPos) { + smv.decrementMovableContainerLeftPos(newMinPos); + + targetPos = stc.rtl ? { right: smv.getMovableContainerCssLeftVal() } : { left: smv.getMovableContainerCssLeftVal() }; + + stc.$movableContainer.stop().animate(targetPos, 'fast', function() { + smv.refreshScrollArrowsDisabledState(); + }); + } else { + smv.refreshScrollArrowsDisabledState(); + } + }); + }; + + }(ScrollMovement.prototype)); + + /* ********************************************************************** + * ScrollingTabsControl - Class that each directive will instantiate + * **********************************************************************/ + function ScrollingTabsControl($tabsContainer) { + var stc = this; + + stc.$tabsContainer = $tabsContainer; + stc.instanceId = $.fn.scrollingTabs.nextInstanceId++; + + stc.movableContainerLeftPos = 0; + stc.scrollArrowsVisible = false; + stc.scrollToTabEdge = false; + stc.disableScrollArrowsOnFullyScrolled = false; + stc.reverseScroll = false; + stc.widthMultiplier = 1; + + stc.scrollMovement = new ScrollMovement(stc); + stc.eventHandlers = new EventHandlers(stc); + stc.elementsHandler = new ElementsHandler(stc); + } + + // prototype methods + (function (p) { + p.initTabs = function (options, $scroller, readyCallback, attachTabContentToDomCallback) { + var stc = this, + elementsHandler = stc.elementsHandler, + num; + + if (options.enableRtlSupport && $('html').attr('dir') === 'rtl') { + stc.rtl = true; + } + + if (options.scrollToTabEdge) { + stc.scrollToTabEdge = true; + } + + if (options.disableScrollArrowsOnFullyScrolled) { + stc.disableScrollArrowsOnFullyScrolled = true; + } + + if (options.reverseScroll) { + stc.reverseScroll = true; + } + + if (options.widthMultiplier !== 1) { + num = Number(options.widthMultiplier); // handle string value + + if (!isNaN(num)) { + stc.widthMultiplier = num; + } + } + + if (options.bootstrapVersion.toString().charAt(0) === '4') { + stc.usingBootstrap4 = true; + } + + setTimeout(initTabsAfterTimeout, 100); + + function initTabsAfterTimeout() { + var actionsTaken; + + // if we're just wrapping non-data-driven tabs, the user might + // have the .nav-tabs hidden to prevent the clunky flash of + // multi-line tabs on page refresh, so we need to make sure + // they're visible before trying to wrap them + $scroller.find('.nav-tabs').show(); + + elementsHandler.initElements(options); + actionsTaken = elementsHandler.refreshAllElementSizes(); + + $scroller.css('visibility', 'visible'); + + if (attachTabContentToDomCallback) { + attachTabContentToDomCallback(); + } + + if (readyCallback) { + readyCallback(); + } + } + }; + + p.scrollToActiveTab = function(options) { + var stc = this, + smv = stc.scrollMovement; + + smv.scrollToActiveTab(options); + }; + }(ScrollingTabsControl.prototype)); + + + /* exported buildNavTabsAndTabContentForTargetElementInstance */ + var tabElements = (function () { + + return { + getElTabPaneForLi: getElTabPaneForLi, + getNewElNavTabs: getNewElNavTabs, + getNewElScrollerElementWrappingNavTabsInstance: getNewElScrollerElementWrappingNavTabsInstance, + getNewElTabAnchor: getNewElTabAnchor, + getNewElTabContent: getNewElTabContent, + getNewElTabLi: getNewElTabLi, + getNewElTabPane: getNewElTabPane + }; + + /////////////////// + + // ---- retrieve existing elements from the DOM ---------- + function getElTabPaneForLi($li) { + return $($li.find('a').attr('href')); + } + + + // ---- create new elements ---------- + function getNewElNavTabs() { + return $(''); + } + + function getNewElScrollerElementWrappingNavTabsInstance($navTabsInstance, settings) { + var $tabsContainer = $('
    '), + leftArrowContent = settings.leftArrowContent || '
    ', + $leftArrow = $(leftArrowContent), + rightArrowContent = settings.rightArrowContent || '
    ', + $rightArrow = $(rightArrowContent), + $fixedContainer = $('
    '), + $movableContainer = $('
    '); + + if (settings.disableScrollArrowsOnFullyScrolled) { + $leftArrow.add($rightArrow).addClass(CONSTANTS.CSS_CLASSES.SCROLL_ARROW_DISABLE); + } + + return $tabsContainer + .append($leftArrow, + $fixedContainer.append($movableContainer.append($navTabsInstance)), + $rightArrow); + } + + function getNewElTabAnchor(tab, propNames) { + return $('') + .attr('href', '#' + tab[propNames.paneId]) + .html(tab[propNames.title]); + } + + function getNewElTabContent() { + return $('
    '); + } + + function getNewElTabLi(tab, propNames, options) { + var liContent = options.tabLiContent || '
  • ', + $li = $(liContent), + $a = getNewElTabAnchor(tab, propNames).appendTo($li); + + if (tab[propNames.disabled]) { + $li.addClass('disabled'); + $a.attr('data-toggle', ''); + } else if (options.forceActiveTab && tab[propNames.active]) { + $li.addClass('active'); + } + + if (options.tabPostProcessor) { + options.tabPostProcessor($li, $a); + } + + return $li; + } + + function getNewElTabPane(tab, propNames, options) { + var $pane = $('
    ') + .attr('id', tab[propNames.paneId]) + .html(tab[propNames.content]); + + if (options.forceActiveTab && tab[propNames.active]) { + $pane.addClass('active'); + } + + return $pane; + } + + + }()); // tabElements + + var tabUtils = (function () { + + return { + didTabOrderChange: didTabOrderChange, + getIndexOfClosestEnabledTab: getIndexOfClosestEnabledTab, + getTabIndexByPaneId: getTabIndexByPaneId, + storeDataOnLiEl: storeDataOnLiEl + }; + + /////////////////// + + function didTabOrderChange($currTabLis, updatedTabs, propNames) { + var isTabOrderChanged = false; + + $currTabLis.each(function (currDomIdx) { + var newIdx = getTabIndexByPaneId(updatedTabs, propNames.paneId, $(this).data('tab')[propNames.paneId]); + + if ((newIdx > -1) && (newIdx !== currDomIdx)) { // tab moved + isTabOrderChanged = true; + return false; // exit .each() loop + } + }); + + return isTabOrderChanged; + } + + function getIndexOfClosestEnabledTab($currTabLis, startIndex) { + var lastIndex = $currTabLis.length - 1, + closestIdx = -1, + incrementFromStartIndex = 0, + testIdx = 0; + + // expand out from the current tab looking for an enabled tab; + // we prefer the tab after us over the tab before + while ((closestIdx === -1) && (testIdx >= 0)) { + + if ( (((testIdx = startIndex + (++incrementFromStartIndex)) <= lastIndex) && + !$currTabLis.eq(testIdx).hasClass('disabled')) || + (((testIdx = startIndex - incrementFromStartIndex) >= 0) && + !$currTabLis.eq(testIdx).hasClass('disabled')) ) { + + closestIdx = testIdx; + + } + } + + return closestIdx; + } + + function getTabIndexByPaneId(tabs, paneIdPropName, paneId) { + var idx = -1; + + tabs.some(function (tab, i) { + if (tab[paneIdPropName] === paneId) { + idx = i; + return true; // exit loop + } + }); + + return idx; + } + + function storeDataOnLiEl($li, tabs, index) { + $li.data({ + tab: $.extend({}, tabs[index]), // store a clone so we can check for changes + index: index + }); + } + + }()); // tabUtils + + function buildNavTabsAndTabContentForTargetElementInstance($targetElInstance, settings, readyCallback) { + var tabs = settings.tabs, + propNames = { + paneId: settings.propPaneId, + title: settings.propTitle, + active: settings.propActive, + disabled: settings.propDisabled, + content: settings.propContent + }, + ignoreTabPanes = settings.ignoreTabPanes, + hasTabContent = tabs.length && tabs[0][propNames.content] !== undefined, + $navTabs = tabElements.getNewElNavTabs(), + $tabContent = tabElements.getNewElTabContent(), + $scroller, + attachTabContentToDomCallback = ignoreTabPanes ? null : function() { + $scroller.after($tabContent); + }; + + if (!tabs.length) { + return; + } + + tabs.forEach(function(tab, index) { + var options = { + forceActiveTab: true, + tabLiContent: settings.tabsLiContent && settings.tabsLiContent[index], + tabPostProcessor: settings.tabsPostProcessors && settings.tabsPostProcessors[index] + }; + + tabElements + .getNewElTabLi(tab, propNames, options) + .appendTo($navTabs); + + // build the tab panes if we weren't told to ignore them and there's + // tab content data available + if (!ignoreTabPanes && hasTabContent) { + tabElements + .getNewElTabPane(tab, propNames, options) + .appendTo($tabContent); + } + }); + + $scroller = wrapNavTabsInstanceInScroller($navTabs, + settings, + readyCallback, + attachTabContentToDomCallback); + + $scroller.appendTo($targetElInstance); + + $targetElInstance.data({ + scrtabs: { + tabs: tabs, + propNames: propNames, + ignoreTabPanes: ignoreTabPanes, + hasTabContent: hasTabContent, + tabsLiContent: settings.tabsLiContent, + tabsPostProcessors: settings.tabsPostProcessors, + scroller: $scroller + } + }); + + // once the nav-tabs are wrapped in the scroller, attach each tab's + // data to it for reference later; we need to wait till they're + // wrapped in the scroller because we wrap a *clone* of the nav-tabs + // we built above, not the original nav-tabs + $scroller.find('.nav-tabs > li').each(function (index) { + tabUtils.storeDataOnLiEl($(this), tabs, index); + }); + + return $targetElInstance; + } + + + function wrapNavTabsInstanceInScroller($navTabsInstance, settings, readyCallback, attachTabContentToDomCallback) { + // Remove tab data stored by Bootstrap in order to fix tabs that were already visited + $navTabsInstance + .find('a[data-toggle="tab"]') + .removeData(CONSTANTS.DATA_KEY_BOOTSTRAP_TAB); + + var $scroller = tabElements.getNewElScrollerElementWrappingNavTabsInstance($navTabsInstance.clone(true), settings), // use clone because we replaceWith later + scrollingTabsControl = new ScrollingTabsControl($scroller), + navTabsInstanceData = $navTabsInstance.data('scrtabs'); + + if (!navTabsInstanceData) { + $navTabsInstance.data('scrtabs', { + scroller: $scroller + }); + } else { + navTabsInstanceData.scroller = $scroller; + } + + $navTabsInstance.replaceWith($scroller.css('visibility', 'hidden')); + + if (settings.tabClickHandler && (typeof settings.tabClickHandler === 'function')) { + $scroller.hasTabClickHandler = true; + scrollingTabsControl.tabClickHandler = settings.tabClickHandler; + } + + $scroller.initTabs = function () { + scrollingTabsControl.initTabs(settings, + $scroller, + readyCallback, + attachTabContentToDomCallback); + }; + + $scroller.scrollToActiveTab = function() { + scrollingTabsControl.scrollToActiveTab(settings); + }; + + $scroller.initTabs(); + + listenForDropdownMenuTabs($scroller, scrollingTabsControl); + + return $scroller; + } + + /* exported listenForDropdownMenuTabs, + refreshTargetElementInstance, + scrollToActiveTab */ + function checkForTabAdded(refreshData) { + var updatedTabsArray = refreshData.updatedTabsArray, + updatedTabsLiContent = refreshData.updatedTabsLiContent || [], + updatedTabsPostProcessors = refreshData.updatedTabsPostProcessors || [], + propNames = refreshData.propNames, + ignoreTabPanes = refreshData.ignoreTabPanes, + options = refreshData.options, + $currTabLis = refreshData.$currTabLis, + $navTabs = refreshData.$navTabs, + $currTabContentPanesContainer = ignoreTabPanes ? null : refreshData.$currTabContentPanesContainer, + $currTabContentPanes = ignoreTabPanes ? null : refreshData.$currTabContentPanes, + isInitTabsRequired = false; + + // make sure each tab in the updated tabs array has a corresponding DOM element + updatedTabsArray.forEach(function (tab, idx) { + var $li = $currTabLis.find('a[href="#' + tab[propNames.paneId] + '"]'), + isTabIdxPastCurrTabs = (idx >= $currTabLis.length), + $pane; + + if (!$li.length) { // new tab + isInitTabsRequired = true; + + // add the tab, add its pane (if necessary), and refresh the scroller + options.tabLiContent = updatedTabsLiContent[idx]; + options.tabPostProcessor = updatedTabsPostProcessors[idx]; + $li = tabElements.getNewElTabLi(tab, propNames, options); + tabUtils.storeDataOnLiEl($li, updatedTabsArray, idx); + + if (isTabIdxPastCurrTabs) { // append to end of current tabs + $li.appendTo($navTabs); + } else { // insert in middle of current tabs + $li.insertBefore($currTabLis.eq(idx)); + } + + if (!ignoreTabPanes && tab[propNames.content] !== undefined) { + $pane = tabElements.getNewElTabPane(tab, propNames, options); + if (isTabIdxPastCurrTabs) { // append to end of current tabs + $pane.appendTo($currTabContentPanesContainer); + } else { // insert in middle of current tabs + $pane.insertBefore($currTabContentPanes.eq(idx)); + } + } + + } + + }); + + return isInitTabsRequired; + } + + function checkForTabPropertiesUpdated(refreshData) { + var tabLiData = refreshData.tabLi, + ignoreTabPanes = refreshData.ignoreTabPanes, + $li = tabLiData.$li, + $contentPane = tabLiData.$contentPane, + origTabData = tabLiData.origTabData, + newTabData = tabLiData.newTabData, + propNames = refreshData.propNames, + isInitTabsRequired = false; + + // update tab title if necessary + if (origTabData[propNames.title] !== newTabData[propNames.title]) { + $li.find('a[role="tab"]') + .html(origTabData[propNames.title] = newTabData[propNames.title]); + + isInitTabsRequired = true; + } + + // update tab disabled state if necessary + if (origTabData[propNames.disabled] !== newTabData[propNames.disabled]) { + if (newTabData[propNames.disabled]) { // enabled -> disabled + $li.addClass('disabled'); + $li.find('a[role="tab"]').attr('data-toggle', ''); + } else { // disabled -> enabled + $li.removeClass('disabled'); + $li.find('a[role="tab"]').attr('data-toggle', 'tab'); + } + + origTabData[propNames.disabled] = newTabData[propNames.disabled]; + isInitTabsRequired = true; + } + + // update tab active state if necessary + if (refreshData.options.forceActiveTab) { + // set the active tab based on the tabs array regardless of the current + // DOM state, which could have been changed by the user clicking a tab + // without those changes being reflected back to the tab data + $li[newTabData[propNames.active] ? 'addClass' : 'removeClass']('active'); + + $contentPane[newTabData[propNames.active] ? 'addClass' : 'removeClass']('active'); + + origTabData[propNames.active] = newTabData[propNames.active]; + + isInitTabsRequired = true; + } + + // update tab content pane if necessary + if (!ignoreTabPanes && origTabData[propNames.content] !== newTabData[propNames.content]) { + $contentPane.html(origTabData[propNames.content] = newTabData[propNames.content]); + isInitTabsRequired = true; + } + + return isInitTabsRequired; + } + + function checkForTabRemoved(refreshData) { + var tabLiData = refreshData.tabLi, + ignoreTabPanes = refreshData.ignoreTabPanes, + $li = tabLiData.$li, + idxToMakeActive; + + if (tabLiData.newIdx !== -1) { // tab was not removed--it has a valid index + return false; + } + + // if this was the active tab, make the closest enabled tab active + if ($li.hasClass('active')) { + + idxToMakeActive = tabUtils.getIndexOfClosestEnabledTab(refreshData.$currTabLis, tabLiData.currDomIdx); + if (idxToMakeActive > -1) { + refreshData.$currTabLis + .eq(idxToMakeActive) + .addClass('active'); + + if (!ignoreTabPanes) { + refreshData.$currTabContentPanes + .eq(idxToMakeActive) + .addClass('active'); + } + } + } + + $li.remove(); + + if (!ignoreTabPanes) { + tabLiData.$contentPane.remove(); + } + + return true; + } + + function checkForTabsOrderChanged(refreshData) { + var $currTabLis = refreshData.$currTabLis, + updatedTabsArray = refreshData.updatedTabsArray, + propNames = refreshData.propNames, + ignoreTabPanes = refreshData.ignoreTabPanes, + newTabsCollection = [], + newTabPanesCollection = ignoreTabPanes ? null : []; + + if (!tabUtils.didTabOrderChange($currTabLis, updatedTabsArray, propNames)) { + return false; + } + + // the tab order changed... + updatedTabsArray.forEach(function (t) { + var paneId = t[propNames.paneId]; + + newTabsCollection.push( + $currTabLis + .find('a[role="tab"][href="#' + paneId + '"]') + .parent('li') + ); + + if (!ignoreTabPanes) { + newTabPanesCollection.push($('#' + paneId)); + } + }); + + refreshData.$navTabs.append(newTabsCollection); + + if (!ignoreTabPanes) { + refreshData.$currTabContentPanesContainer.append(newTabPanesCollection); + } + + return true; + } + + function checkForTabsRemovedOrUpdated(refreshData) { + var $currTabLis = refreshData.$currTabLis, + updatedTabsArray = refreshData.updatedTabsArray, + propNames = refreshData.propNames, + isInitTabsRequired = false; + + + $currTabLis.each(function (currDomIdx) { + var $li = $(this), + origTabData = $li.data('tab'), + newIdx = tabUtils.getTabIndexByPaneId(updatedTabsArray, propNames.paneId, origTabData[propNames.paneId]), + newTabData = (newIdx > -1) ? updatedTabsArray[newIdx] : null; + + refreshData.tabLi = { + $li: $li, + currDomIdx: currDomIdx, + newIdx: newIdx, + $contentPane: tabElements.getElTabPaneForLi($li), + origTabData: origTabData, + newTabData: newTabData + }; + + if (checkForTabRemoved(refreshData)) { + isInitTabsRequired = true; + return; // continue to next $li in .each() since we removed this tab + } + + if (checkForTabPropertiesUpdated(refreshData)) { + isInitTabsRequired = true; + } + }); + + return isInitTabsRequired; + } + + function listenForDropdownMenuTabs($scroller, stc) { + var $ddMenu; + + // for dropdown menus to show, we need to move them out of the + // scroller and append them to the body + $scroller + .on(CONSTANTS.EVENTS.DROPDOWN_MENU_SHOW, handleDropdownShow) + .on(CONSTANTS.EVENTS.DROPDOWN_MENU_HIDE, handleDropdownHide); + + function handleDropdownHide(e) { + // move the dropdown menu back into its tab + $(e.target).append($ddMenu.off(CONSTANTS.EVENTS.CLICK)); + } + + function handleDropdownShow(e) { + var $ddParentTabLi = $(e.target), + ddLiOffset = $ddParentTabLi.offset(), + $currActiveTab = $scroller.find('li[role="presentation"].active'), + ddMenuRightX, + tabsContainerMaxX, + ddMenuTargetLeft; + + $ddMenu = $ddParentTabLi + .find('.dropdown-menu') + .attr('data-' + CONSTANTS.DATA_KEY_DDMENU_MODIFIED, true); + + // if the dropdown's parent tab li isn't already active, + // we need to deactivate any active menu item in the dropdown + if ($currActiveTab[0] !== $ddParentTabLi[0]) { + $ddMenu.find('li.active').removeClass('active'); + } + + // we need to do our own click handling because the built-in + // bootstrap handlers won't work since we moved the dropdown + // menu outside the tabs container + $ddMenu.on(CONSTANTS.EVENTS.CLICK, 'a[role="tab"]', handleClickOnDropdownMenuItem); + + $('body').append($ddMenu); + + // make sure the menu doesn't go off the right side of the page + ddMenuRightX = $ddMenu.width() + ddLiOffset.left; + tabsContainerMaxX = $scroller.width() - (stc.$slideRightArrow.outerWidth() + 1); + ddMenuTargetLeft = ddLiOffset.left; + + if (ddMenuRightX > tabsContainerMaxX) { + ddMenuTargetLeft -= (ddMenuRightX - tabsContainerMaxX); + } + + $ddMenu.css({ + 'display': 'block', + 'top': ddLiOffset.top + $ddParentTabLi.outerHeight() - 2, + 'left': ddMenuTargetLeft + }); + + function handleClickOnDropdownMenuItem() { + /* jshint validthis: true */ + var $selectedMenuItemAnc = $(this), + $selectedMenuItemLi = $selectedMenuItemAnc.parent('li'), + $selectedMenuItemDropdownMenu = $selectedMenuItemLi.parent('.dropdown-menu'), + targetPaneId = $selectedMenuItemAnc.attr('href'); + + if ($selectedMenuItemLi.hasClass('active')) { + return; + } + + // once we select a menu item from the dropdown, deactivate + // the current tab (unless it's our parent tab), deactivate + // any active dropdown menu item, make our parent tab active + // (if it's not already), and activate the selected menu item + $scroller + .find('li.active') + .not($ddParentTabLi) + .add($selectedMenuItemDropdownMenu.find('li.active')) + .removeClass('active'); + + $ddParentTabLi + .add($selectedMenuItemLi) + .addClass('active'); + + // manually deactivate current active pane and activate our pane + $('.tab-content .tab-pane.active').removeClass('active'); + $(targetPaneId).addClass('active'); + } + + } + } + + function refreshDataDrivenTabs($container, options) { + var instanceData = $container.data().scrtabs, + scroller = instanceData.scroller, + $navTabs = $container.find('.scrtabs-tab-container .nav-tabs'), + $currTabContentPanesContainer = $container.find('.tab-content'), + isInitTabsRequired = false, + refreshData = { + options: options, + updatedTabsArray: instanceData.tabs, + updatedTabsLiContent: instanceData.tabsLiContent, + updatedTabsPostProcessors: instanceData.tabsPostProcessors, + propNames: instanceData.propNames, + ignoreTabPanes: instanceData.ignoreTabPanes, + $navTabs: $navTabs, + $currTabLis: $navTabs.find('> li'), + $currTabContentPanesContainer: $currTabContentPanesContainer, + $currTabContentPanes: $currTabContentPanesContainer.find('.tab-pane') + }; + + // to preserve the tab positions if we're just adding or removing + // a tab, don't completely rebuild the tab structure, but check + // for differences between the new tabs array and the old + if (checkForTabAdded(refreshData)) { + isInitTabsRequired = true; + } + + if (checkForTabsOrderChanged(refreshData)) { + isInitTabsRequired = true; + } + + if (checkForTabsRemovedOrUpdated(refreshData)) { + isInitTabsRequired = true; + } + + if (isInitTabsRequired) { + scroller.initTabs(); + } + + return isInitTabsRequired; + } + + function refreshTargetElementInstance($container, options) { + if (!$container.data('scrtabs')) { // target element doesn't have plugin on it + return; + } + + // force a refresh if the tabs are static html or they're data-driven + // but the data didn't change so we didn't call initTabs() + if ($container.data('scrtabs').isWrapperOnly || !refreshDataDrivenTabs($container, options)) { + $('body').trigger(CONSTANTS.EVENTS.FORCE_REFRESH); + } + } + + function scrollToActiveTab() { + /* jshint validthis: true */ + var $targetElInstance = $(this), + scrtabsData = $targetElInstance.data('scrtabs'); + + if (!scrtabsData) { + return; + } + + scrtabsData.scroller.scrollToActiveTab(); + } + + var methods = { + destroy: function() { + var $targetEls = this; + + return $targetEls.each(destroyPlugin); + }, + + init: function(options) { + var $targetEls = this, + targetElsLastIndex = $targetEls.length - 1, + settings = $.extend({}, $.fn.scrollingTabs.defaults, options || {}); + + // ---- tabs NOT data-driven ------------------------- + if (!settings.tabs) { + + // just wrap the selected .nav-tabs element(s) in the scroller + return $targetEls.each(function(index) { + var dataObj = { + isWrapperOnly: true + }, + $targetEl = $(this).data({ scrtabs: dataObj }), + readyCallback = (index < targetElsLastIndex) ? null : function() { + $targetEls.trigger(CONSTANTS.EVENTS.TABS_READY); + }; + + wrapNavTabsInstanceInScroller($targetEl, settings, readyCallback); + }); + + } + + // ---- tabs data-driven ------------------------- + return $targetEls.each(function (index) { + var $targetEl = $(this), + readyCallback = (index < targetElsLastIndex) ? null : function() { + $targetEls.trigger(CONSTANTS.EVENTS.TABS_READY); + }; + + buildNavTabsAndTabContentForTargetElementInstance($targetEl, settings, readyCallback); + }); + }, + + refresh: function(options) { + var $targetEls = this, + settings = $.extend({}, $.fn.scrollingTabs.defaults, options || {}); + + return $targetEls.each(function () { + refreshTargetElementInstance($(this), settings); + }); + }, + + scrollToActiveTab: function() { + return this.each(scrollToActiveTab); + } + }; + + function destroyPlugin() { + /* jshint validthis: true */ + var $targetElInstance = $(this), + scrtabsData = $targetElInstance.data('scrtabs'), + $tabsContainer; + + if (!scrtabsData) { + return; + } + + if (scrtabsData.enableSwipingElement === 'self') { + $targetElInstance.removeClass(CONSTANTS.CSS_CLASSES.ALLOW_SCROLLBAR); + } else if (scrtabsData.enableSwipingElement === 'parent') { + $targetElInstance.closest('.scrtabs-tab-container').parent().removeClass(CONSTANTS.CSS_CLASSES.ALLOW_SCROLLBAR); + } + + scrtabsData.scroller + .off(CONSTANTS.EVENTS.DROPDOWN_MENU_SHOW) + .off(CONSTANTS.EVENTS.DROPDOWN_MENU_HIDE); + + // if there were any dropdown menus opened, remove the css we added to + // them so they would display correctly + scrtabsData.scroller + .find('[data-' + CONSTANTS.DATA_KEY_DDMENU_MODIFIED + ']') + .css({ + display: '', + left: '', + top: '' + }) + .off(CONSTANTS.EVENTS.CLICK) + .removeAttr('data-' + CONSTANTS.DATA_KEY_DDMENU_MODIFIED); + + if (scrtabsData.scroller.hasTabClickHandler) { + $targetElInstance + .find('a[data-toggle="tab"]') + .off('.scrtabs'); + } + + if (scrtabsData.isWrapperOnly) { // we just wrapped nav-tabs markup, so restore it + // $targetElInstance is the ul.nav-tabs + $tabsContainer = $targetElInstance.parents('.scrtabs-tab-container'); + + if ($tabsContainer.length) { + $tabsContainer.replaceWith($targetElInstance); + } + + } else { // we generated the tabs from data so destroy everything we created + if (scrtabsData.scroller && scrtabsData.scroller.initTabs) { + scrtabsData.scroller.initTabs = null; + } + + // $targetElInstance is the container for the ul.nav-tabs we generated + $targetElInstance + .find('.scrtabs-tab-container') + .add('.tab-content') + .remove(); + } + + $targetElInstance.removeData('scrtabs'); + + while(--$.fn.scrollingTabs.nextInstanceId >= 0) { + $(window).off(CONSTANTS.EVENTS.WINDOW_RESIZE + $.fn.scrollingTabs.nextInstanceId); + } + + $('body').off(CONSTANTS.EVENTS.FORCE_REFRESH); + } + + + $.fn.scrollingTabs = function(methodOrOptions) { + + if (methods[methodOrOptions]) { + return methods[methodOrOptions].apply(this, Array.prototype.slice.call(arguments, 1)); + } else if (!methodOrOptions || (typeof methodOrOptions === 'object')) { + return methods.init.apply(this, arguments); + } else { + $.error('Method ' + methodOrOptions + ' does not exist on $.scrollingTabs.'); + } + }; + + $.fn.scrollingTabs.nextInstanceId = 0; + + $.fn.scrollingTabs.defaults = { + tabs: null, + propPaneId: 'paneId', + propTitle: 'title', + propActive: 'active', + propDisabled: 'disabled', + propContent: 'content', + ignoreTabPanes: false, + scrollToTabEdge: false, + disableScrollArrowsOnFullyScrolled: false, + forceActiveTab: false, + reverseScroll: false, + widthMultiplier: 1, + tabClickHandler: null, + cssClassLeftArrow: 'glyphicon glyphicon-chevron-left', + cssClassRightArrow: 'glyphicon glyphicon-chevron-right', + leftArrowContent: '', + rightArrowContent: '', + tabsLiContent: null, + tabsPostProcessors: null, + enableSwiping: false, + enableRtlSupport: false, + handleDelayedScrollbar: false, + bootstrapVersion: 3 + }; + + + +}(jQuery, window)); diff --git a/view/bootstrap/jquery-bootstrap-scrolling-tabs/jquery.scrolling-tabs.min.css b/view/bootstrap/jquery-bootstrap-scrolling-tabs/jquery.scrolling-tabs.min.css new file mode 100644 index 000000000..5e406e91f --- /dev/null +++ b/view/bootstrap/jquery-bootstrap-scrolling-tabs/jquery.scrolling-tabs.min.css @@ -0,0 +1,8 @@ +/** + * jquery-bootstrap-scrolling-tabs + * @version v2.6.1 + * @link https://github.com/mikejacobson/jquery-bootstrap-scrolling-tabs + * @author Mike Jacobson + * @license MIT License, http://www.opensource.org/licenses/MIT + */ +.scrtabs-tab-container *{box-sizing:border-box}.scrtabs-tab-container{height:42px}.scrtabs-tab-container .tab-content{clear:left}.scrtabs-tab-container.scrtabs-bootstrap4 .scrtabs-tabs-movable-container>.navbar-nav{-ms-flex-direction:row;flex-direction:row}.scrtabs-tabs-fixed-container{float:left;height:42px;overflow:hidden;width:100%}.scrtabs-tabs-movable-container{position:relative}.scrtabs-tabs-movable-container .tab-content{display:none}.scrtabs-tab-container.scrtabs-rtl .scrtabs-tabs-movable-container>ul.nav-tabs{padding-right:0}.scrtabs-tab-scroll-arrow{border:1px solid #ddd;border-top:none;color:#428bca;display:none;float:left;font-size:12px;height:42px;margin-bottom:-1px;padding-left:2px;padding-top:13px;width:20px}.scrtabs-tab-scroll-arrow:hover{background-color:#eee}.scrtabs-tab-scroll-arrow,.scrtabs-tab-scroll-arrow .scrtabs-click-target{cursor:pointer}.scrtabs-tab-scroll-arrow.scrtabs-with-click-target{cursor:default}.scrtabs-tab-scroll-arrow.scrtabs-disable,.scrtabs-tab-scroll-arrow.scrtabs-disable .scrtabs-click-target{color:#ddd;cursor:default}.scrtabs-tab-scroll-arrow.scrtabs-disable:hover{background-color:initial}.scrtabs-tabs-fixed-container ul.nav-tabs>li{white-space:nowrap} \ No newline at end of file diff --git a/view/bootstrap/jquery-bootstrap-scrolling-tabs/jquery.scrolling-tabs.min.js b/view/bootstrap/jquery-bootstrap-scrolling-tabs/jquery.scrolling-tabs.min.js new file mode 100644 index 000000000..c5deb89b6 --- /dev/null +++ b/view/bootstrap/jquery-bootstrap-scrolling-tabs/jquery.scrolling-tabs.min.js @@ -0,0 +1,8 @@ +/** + * jquery-bootstrap-scrolling-tabs + * @version v2.6.1 + * @link https://github.com/mikejacobson/jquery-bootstrap-scrolling-tabs + * @author Mike Jacobson + * @license MIT License, http://www.opensource.org/licenses/MIT + */ +!function(e,t){"use strict";function n(e){this.stc=e}function r(e){this.stc=e}function a(e){this.stc=e}function o(t){var o=this;o.$tabsContainer=t,o.instanceId=e.fn.scrollingTabs.nextInstanceId++,o.movableContainerLeftPos=0,o.scrollArrowsVisible=!1,o.scrollToTabEdge=!1,o.disableScrollArrowsOnFullyScrolled=!1,o.reverseScroll=!1,o.widthMultiplier=1,o.scrollMovement=new a(o),o.eventHandlers=new r(o),o.elementsHandler=new n(o)}function i(t,n,r){var a,o=n.tabs,i={paneId:n.propPaneId,title:n.propTitle,active:n.propActive,disabled:n.propDisabled,content:n.propContent},l=n.ignoreTabPanes,c=o.length&&void 0!==o[0][i.content],d=A.getNewElNavTabs(),b=A.getNewElTabContent(),f=l?null:function(){a.after(b)};if(o.length)return o.forEach(function(e,t){var r={forceActiveTab:!0,tabLiContent:n.tabsLiContent&&n.tabsLiContent[t],tabPostProcessor:n.tabsPostProcessors&&n.tabsPostProcessors[t]};A.getNewElTabLi(e,i,r).appendTo(d),!l&&c&&A.getNewElTabPane(e,i,r).appendTo(b)}),a=s(d,n,r,f),a.appendTo(t),t.data({scrtabs:{tabs:o,propNames:i,ignoreTabPanes:l,hasTabContent:c,tabsLiContent:n.tabsLiContent,tabsPostProcessors:n.tabsPostProcessors,scroller:a}}),a.find(".nav-tabs > li").each(function(t){L.storeDataOnLiEl(e(this),o,t)}),t}function s(e,t,n,r){e.find('a[data-toggle="tab"]').removeData(T.DATA_KEY_BOOTSTRAP_TAB);var a=A.getNewElScrollerElementWrappingNavTabsInstance(e.clone(!0),t),i=new o(a),s=e.data("scrtabs");return s?s.scroller=a:e.data("scrtabs",{scroller:a}),e.replaceWith(a.css("visibility","hidden")),t.tabClickHandler&&"function"==typeof t.tabClickHandler&&(a.hasTabClickHandler=!0,i.tabClickHandler=t.tabClickHandler),a.initTabs=function(){i.initTabs(t,a,n,r)},a.scrollToActiveTab=function(){i.scrollToActiveTab(t)},a.initTabs(),C(a,i),a}function l(e){var t=e.updatedTabsArray,n=e.updatedTabsLiContent||[],r=e.updatedTabsPostProcessors||[],a=e.propNames,o=e.ignoreTabPanes,i=e.options,s=e.$currTabLis,l=e.$navTabs,c=o?null:e.$currTabContentPanesContainer,d=o?null:e.$currTabContentPanes,b=!1;return t.forEach(function(e,f){var C,v=s.find('a[href="#'+e[a.paneId]+'"]'),u=f>=s.length;v.length||(b=!0,i.tabLiContent=n[f],i.tabPostProcessor=r[f],v=A.getNewElTabLi(e,a,i),L.storeDataOnLiEl(v,t,f),u?v.appendTo(l):v.insertBefore(s.eq(f)),o||void 0===e[a.content]||(C=A.getNewElTabPane(e,a,i),u?C.appendTo(c):C.insertBefore(d.eq(f))))}),b}function c(e){var t=e.tabLi,n=e.ignoreTabPanes,r=t.$li,a=t.$contentPane,o=t.origTabData,i=t.newTabData,s=e.propNames,l=!1;return o[s.title]!==i[s.title]&&(r.find('a[role="tab"]').html(o[s.title]=i[s.title]),l=!0),o[s.disabled]!==i[s.disabled]&&(i[s.disabled]?(r.addClass("disabled"),r.find('a[role="tab"]').attr("data-toggle","")):(r.removeClass("disabled"),r.find('a[role="tab"]').attr("data-toggle","tab")),o[s.disabled]=i[s.disabled],l=!0),e.options.forceActiveTab&&(r[i[s.active]?"addClass":"removeClass"]("active"),a[i[s.active]?"addClass":"removeClass"]("active"),o[s.active]=i[s.active],l=!0),n||o[s.content]===i[s.content]||(a.html(o[s.content]=i[s.content]),l=!0),l}function d(e){var t,n=e.tabLi,r=e.ignoreTabPanes,a=n.$li;return-1===n.newIdx&&(a.hasClass("active")&&(t=L.getIndexOfClosestEnabledTab(e.$currTabLis,n.currDomIdx))>-1&&(e.$currTabLis.eq(t).addClass("active"),r||e.$currTabContentPanes.eq(t).addClass("active")),a.remove(),r||n.$contentPane.remove(),!0)}function b(t){var n=t.$currTabLis,r=t.updatedTabsArray,a=t.propNames,o=t.ignoreTabPanes,i=[],s=o?null:[];return!!L.didTabOrderChange(n,r,a)&&(r.forEach(function(t){var r=t[a.paneId];i.push(n.find('a[role="tab"][href="#'+r+'"]').parent("li")),o||s.push(e("#"+r))}),t.$navTabs.append(i),o||t.$currTabContentPanesContainer.append(s),!0)}function f(t){var n=t.$currTabLis,r=t.updatedTabsArray,a=t.propNames,o=!1;return n.each(function(n){var i=e(this),s=i.data("tab"),l=L.getTabIndexByPaneId(r,a.paneId,s[a.paneId]),b=l>-1?r[l]:null;if(t.tabLi={$li:i,currDomIdx:n,newIdx:l,$contentPane:A.getElTabPaneForLi(i),origTabData:s,newTabData:b},d(t))return void(o=!0);c(t)&&(o=!0)}),o}function C(t,n){function r(t){e(t.target).append(o.off(T.EVENTS.CLICK))}function a(r){function a(){var n=e(this),r=n.parent("li"),a=r.parent(".dropdown-menu"),o=n.attr("href");r.hasClass("active")||(t.find("li.active").not(c).add(a.find("li.active")).removeClass("active"),c.add(r).addClass("active"),e(".tab-content .tab-pane.active").removeClass("active"),e(o).addClass("active"))}var i,s,l,c=e(r.target),d=c.offset(),b=t.find('li[role="presentation"].active');o=c.find(".dropdown-menu").attr("data-"+T.DATA_KEY_DDMENU_MODIFIED,!0),b[0]!==c[0]&&o.find("li.active").removeClass("active"),o.on(T.EVENTS.CLICK,'a[role="tab"]',a),e("body").append(o),i=o.width()+d.left,s=t.width()-(n.$slideRightArrow.outerWidth()+1),l=d.left,i>s&&(l-=i-s),o.css({display:"block",top:d.top+c.outerHeight()-2,left:l})}var o;t.on(T.EVENTS.DROPDOWN_MENU_SHOW,a).on(T.EVENTS.DROPDOWN_MENU_HIDE,r)}function v(e,t){var n=e.data().scrtabs,r=n.scroller,a=e.find(".scrtabs-tab-container .nav-tabs"),o=e.find(".tab-content"),i=!1,s={options:t,updatedTabsArray:n.tabs,updatedTabsLiContent:n.tabsLiContent,updatedTabsPostProcessors:n.tabsPostProcessors,propNames:n.propNames,ignoreTabPanes:n.ignoreTabPanes,$navTabs:a,$currTabLis:a.find("> li"),$currTabContentPanesContainer:o,$currTabContentPanes:o.find(".tab-pane")};return l(s)&&(i=!0),b(s)&&(i=!0),f(s)&&(i=!0),i&&r.initTabs(),i}function u(t,n){t.data("scrtabs")&&(!t.data("scrtabs").isWrapperOnly&&v(t,n)||e("body").trigger(T.EVENTS.FORCE_REFRESH))}function h(){var t=e(this),n=t.data("scrtabs");n&&n.scroller.scrollToActiveTab()}function S(){var n,r=e(this),a=r.data("scrtabs");if(a){for("self"===a.enableSwipingElement?r.removeClass(T.CSS_CLASSES.ALLOW_SCROLLBAR):"parent"===a.enableSwipingElement&&r.closest(".scrtabs-tab-container").parent().removeClass(T.CSS_CLASSES.ALLOW_SCROLLBAR),a.scroller.off(T.EVENTS.DROPDOWN_MENU_SHOW).off(T.EVENTS.DROPDOWN_MENU_HIDE),a.scroller.find("[data-"+T.DATA_KEY_DDMENU_MODIFIED+"]").css({display:"",left:"",top:""}).off(T.EVENTS.CLICK).removeAttr("data-"+T.DATA_KEY_DDMENU_MODIFIED),a.scroller.hasTabClickHandler&&r.find('a[data-toggle="tab"]').off(".scrtabs"),a.isWrapperOnly?(n=r.parents(".scrtabs-tab-container"),n.length&&n.replaceWith(r)):(a.scroller&&a.scroller.initTabs&&(a.scroller.initTabs=null),r.find(".scrtabs-tab-container").add(".tab-content").remove()),r.removeData("scrtabs");--e.fn.scrollingTabs.nextInstanceId>=0;)e(t).off(T.EVENTS.WINDOW_RESIZE+e.fn.scrollingTabs.nextInstanceId);e("body").off(T.EVENTS.FORCE_REFRESH)}}var T={CONTINUOUS_SCROLLING_TIMEOUT_INTERVAL:50,SCROLL_OFFSET_FRACTION:6,DATA_KEY_DDMENU_MODIFIED:"scrtabsddmenumodified",DATA_KEY_IS_MOUSEDOWN:"scrtabsismousedown",DATA_KEY_BOOTSTRAP_TAB:"bs.tab",CSS_CLASSES:{BOOTSTRAP4:"scrtabs-bootstrap4",RTL:"scrtabs-rtl",SCROLL_ARROW_CLICK_TARGET:"scrtabs-click-target",SCROLL_ARROW_DISABLE:"scrtabs-disable",SCROLL_ARROW_WITH_CLICK_TARGET:"scrtabs-with-click-target"},SLIDE_DIRECTION:{LEFT:1,RIGHT:2},EVENTS:{CLICK:"click.scrtabs",DROPDOWN_MENU_HIDE:"hide.bs.dropdown.scrtabs",DROPDOWN_MENU_SHOW:"show.bs.dropdown.scrtabs",FORCE_REFRESH:"forcerefresh.scrtabs",MOUSEDOWN:"mousedown.scrtabs",MOUSEUP:"mouseup.scrtabs",TABS_READY:"ready.scrtabs",TOUCH_END:"touchend.scrtabs",TOUCH_MOVE:"touchmove.scrtabs",TOUCH_START:"touchstart.scrtabs",WINDOW_RESIZE:"resize.scrtabs"}};!function(t){var n=function(e,t,n){var r;return function(){function a(){n||e.apply(o,i),r=null}var o=this,i=arguments;r?clearTimeout(r):n&&e.apply(o,i),r=setTimeout(a,t||100)}};e.fn[t]=function(e,r){var a=r||T.EVENTS.WINDOW_RESIZE;return e?this.bind(a,n(e)):this.trigger(t)}}("smartresizeScrtabs"),function(n){n.initElements=function(e){var t=this;t.setElementReferences(e),t.setEventListeners(e)},n.listenForTouchEvents=function(){var e,t,n,r=this,a=r.stc,o=a.scrollMovement,i=T.EVENTS,s=!1;a.$movableContainer.on(i.TOUCH_START,function(n){s=!0,t=a.movableContainerLeftPos,e=n.originalEvent.changedTouches[0].pageX}).on(i.TOUCH_END,function(){s=!1}).on(i.TOUCH_MOVE,function(r){if(s){var i=r.originalEvent.changedTouches[0].pageX,l=i-e;a.rtl&&(l=-l);var c;n=t+l,n>0?n=0:(c=o.getMinPos(),n li"),l.$slideLeftArrow=l.reverseScroll?r:a,l.$slideLeftArrowClickTarget=l.reverseScroll?o:i,l.$slideRightArrow=l.reverseScroll?a:r,l.$slideRightArrowClickTarget=l.reverseScroll?i:o,l.$scrollArrows=l.$slideLeftArrow.add(l.$slideRightArrow),l.$win=e(t)},n.setElementWidths=function(){var e=this,t=e.stc;t.winWidth=t.$win.width(),t.scrollArrowsCombinedWidth=t.$slideLeftArrow.outerWidth()+t.$slideRightArrow.outerWidth(),e.setFixedContainerWidth(),e.setMovableContainerWidth()},n.setEventListeners=function(t){var n=this,r=n.stc,a=r.eventHandlers,o=T.EVENTS,i=o.WINDOW_RESIZE+r.instanceId;t.enableSwiping&&n.listenForTouchEvents(),r.$slideLeftArrowClickTarget.off(".scrtabs").on(o.MOUSEDOWN,function(e){a.handleMousedownOnSlideMovContainerLeftArrow.call(a,e)}).on(o.MOUSEUP,function(e){a.handleMouseupOnSlideMovContainerLeftArrow.call(a,e)}).on(o.CLICK,function(e){a.handleClickOnSlideMovContainerLeftArrow.call(a,e)}),r.$slideRightArrowClickTarget.off(".scrtabs").on(o.MOUSEDOWN,function(e){a.handleMousedownOnSlideMovContainerRightArrow.call(a,e)}).on(o.MOUSEUP,function(e){a.handleMouseupOnSlideMovContainerRightArrow.call(a,e)}).on(o.CLICK,function(e){a.handleClickOnSlideMovContainerRightArrow.call(a,e)}),r.tabClickHandler&&r.$tabsLiCollection.find('a[data-toggle="tab"]').off(o.CLICK).on(o.CLICK,r.tabClickHandler),t.handleDelayedScrollbar&&n.listenForDelayedScrollbar(),r.$win.off(i).smartresizeScrtabs(function(e){a.handleWindowResize.call(a,e)},i),e("body").on(T.EVENTS.FORCE_REFRESH,r.elementsHandler.refreshAllElementSizes.bind(r.elementsHandler))},n.listenForDelayedScrollbar=function(){var n=document.createElement("iframe");n.id="scrtabs-scrollbar-resize-listener",n.style.cssText="height: 0; background-color: transparent; margin: 0; padding: 0; overflow: hidden; border-width: 0; position: absolute; width: 100%;",n.onload=function(){function r(){try{e(t).trigger("resize"),a=null}catch(e){}}var a;n.contentWindow.addEventListener("resize",function(){a&&clearTimeout(a),a=setTimeout(r,100)})},document.body.appendChild(n)},n.setFixedContainerWidth=function(){var e=this,t=e.stc,n=t.$tabsContainer.get(0).getBoundingClientRect();t.fixedContainerWidth=n.width||n.right-n.left,t.fixedContainerWidth=t.fixedContainerWidth*t.widthMultiplier,t.$fixedContainer.width(t.fixedContainerWidth)},n.setFixedContainerWidthForHiddenScrollArrows=function(){var e=this,t=e.stc;t.$fixedContainer.width(t.fixedContainerWidth)},n.setFixedContainerWidthForVisibleScrollArrows=function(){var e=this,t=e.stc;t.$fixedContainer.width(t.fixedContainerWidth-t.scrollArrowsCombinedWidth)},n.setMovableContainerWidth=function(){var t=this,n=t.stc,r=n.$tabsUl.find("> li");n.movableContainerWidth=0,r.length&&(r.each(function(){var t=e(this),r=0;n.isNavPills&&(r=parseInt(t.css("margin-left"),10)+parseInt(t.css("margin-right"),10)),n.movableContainerWidth+=t.outerWidth()+r}),n.movableContainerWidth+=1,n.movableContainerWidtht.fixedContainerWidth;n&&!t.scrollArrowsVisible?(t.$scrollArrows.show(),t.scrollArrowsVisible=!0):!n&&t.scrollArrowsVisible&&(t.$scrollArrows.hide(),t.scrollArrowsVisible=!1),t.scrollArrowsVisible?e.setFixedContainerWidthForVisibleScrollArrows():e.setFixedContainerWidthForHiddenScrollArrows()}}(n.prototype),function(e){e.handleClickOnSlideMovContainerLeftArrow=function(){this.stc.scrollMovement.incrementMovableContainerLeft()},e.handleClickOnSlideMovContainerRightArrow=function(){this.stc.scrollMovement.incrementMovableContainerRight()},e.handleMousedownOnSlideMovContainerLeftArrow=function(){var e=this,t=e.stc;t.$slideLeftArrowClickTarget.data(T.DATA_KEY_IS_MOUSEDOWN,!0),t.scrollMovement.continueSlideMovableContainerLeft()},e.handleMousedownOnSlideMovContainerRightArrow=function(){var e=this,t=e.stc;t.$slideRightArrowClickTarget.data(T.DATA_KEY_IS_MOUSEDOWN,!0),t.scrollMovement.continueSlideMovableContainerRight()},e.handleMouseupOnSlideMovContainerLeftArrow=function(){this.stc.$slideLeftArrowClickTarget.data(T.DATA_KEY_IS_MOUSEDOWN,!1)},e.handleMouseupOnSlideMovContainerRightArrow=function(){this.stc.$slideRightArrowClickTarget.data(T.DATA_KEY_IS_MOUSEDOWN,!1)},e.handleWindowResize=function(){var e=this,t=e.stc,n=t.$win.width();if(n===t.winWidth)return!1;t.winWidth=n,t.elementsHandler.refreshAllElementSizes()}}(r.prototype),function(t){t.continueSlideMovableContainerLeft=function(){var e=this,t=e.stc;setTimeout(function(){t.movableContainerLeftPos<=e.getMinPos()||!t.$slideLeftArrowClickTarget.data(T.DATA_KEY_IS_MOUSEDOWN)||e.incrementMovableContainerLeft()||e.continueSlideMovableContainerLeft()},T.CONTINUOUS_SCROLLING_TIMEOUT_INTERVAL)},t.continueSlideMovableContainerRight=function(){var e=this,t=e.stc;setTimeout(function(){t.movableContainerLeftPos>=0||!t.$slideRightArrowClickTarget.data(T.DATA_KEY_IS_MOUSEDOWN)||e.incrementMovableContainerRight()||e.continueSlideMovableContainerRight()},T.CONTINUOUS_SCROLLING_TIMEOUT_INTERVAL)},t.decrementMovableContainerLeftPos=function(e){var t=this,n=t.stc;n.movableContainerLeftPos-=n.fixedContainerWidth/T.SCROLL_OFFSET_FRACTION,n.movableContainerLeftPos0?n.movableContainerLeftPos=0:n.scrollToTabEdge&&t.setMovableContainerLeftPosToTabEdge(T.SLIDE_DIRECTION.RIGHT)),t.slideMovableContainerToLeftPos(),t.enableSlideLeftArrow(),0===n.movableContainerLeftPos},t.refreshScrollArrowsDisabledState=function(){var e=this,t=e.stc;if(t.disableScrollArrowsOnFullyScrolled&&t.scrollArrowsVisible){if(t.movableContainerLeftPos>=0)return e.disableSlideRightArrow(),void e.enableSlideLeftArrow();if(t.movableContainerLeftPos<=e.getMinPos())return e.disableSlideLeftArrow(),void e.enableSlideRightArrow();e.enableSlideLeftArrow(),e.enableSlideRightArrow()}},t.scrollToActiveTab=function(){var e,t,n,r,a,o,i,s,l,c=this,d=c.stc;if(d.scrollArrowsVisible&&(d.usingBootstrap4?(t=d.$tabsUl.find("li > .nav-link.active"),t.length&&(e=t.parent())):e=d.$tabsUl.find("li.active"),e&&e.length)){if(l=d.$slideRightArrow.outerWidth(),o=e.outerWidth(),n=e.offset().left-d.$fixedContainer.offset().left,r=n+o,a=d.fixedContainerWidth-l,d.rtl){if(d.$slideLeftArrow.outerWidth(),n<0)return d.movableContainerLeftPos+=n,c.slideMovableContainerToLeftPos(),!0;if(r>a)return d.movableContainerLeftPos+=r-a+2*l,c.slideMovableContainerToLeftPos(),!0}else{if(r>a)return i=r-a+l,s=d.fixedContainerWidth/2,i+=s-o/2,d.movableContainerLeftPos-=i,c.slideMovableContainerToLeftPos(),!0;if(d.$slideLeftArrow.outerWidth(),n<0)return s=d.fixedContainerWidth/2,d.movableContainerLeftPos+=-n+s-o/2,c.slideMovableContainerToLeftPos(),!0}return!1}},t.setMovableContainerLeftPosToTabEdge=function(t){var n=this,r=n.stc,a=-r.movableContainerLeftPos,o=0;r.$tabsLiCollection.each(function(){var n=e(this).width();if((o+=n)>a)return r.movableContainerLeftPos=t===T.SLIDE_DIRECTION.RIGHT?-(o-n):-o,!1})},t.slideMovableContainerToLeftPos=function(){var e,t=this,n=t.stc,r=t.getMinPos();n.movableContainerLeftPos>0?n.movableContainerLeftPos=0:n.movableContainerLeftPos')}function r(t,n){var r=e('
    '),a=n.leftArrowContent||'
    ',o=e(a),i=n.rightArrowContent||'
    ',s=e(i),l=e('
    '),c=e('
    ');return n.disableScrollArrowsOnFullyScrolled&&o.add(s).addClass(T.CSS_CLASSES.SCROLL_ARROW_DISABLE),r.append(o,l.append(c.append(t)),s)}function a(t,n){return e('').attr("href","#"+t[n.paneId]).html(t[n.title])}function o(){return e('
    ')}function i(t,n,r){var o=r.tabLiContent||'
  • ',i=e(o),s=a(t,n).appendTo(i);return t[n.disabled]?(i.addClass("disabled"),s.attr("data-toggle","")):r.forceActiveTab&&t[n.active]&&i.addClass("active"),r.tabPostProcessor&&r.tabPostProcessor(i,s),i}function s(t,n,r){var a=e('
    ').attr("id",t[n.paneId]).html(t[n.content]);return r.forceActiveTab&&t[n.active]&&a.addClass("active"),a}return{getElTabPaneForLi:t,getNewElNavTabs:n,getNewElScrollerElementWrappingNavTabsInstance:r,getNewElTabAnchor:a,getNewElTabContent:o,getNewElTabLi:i,getNewElTabPane:s}}(),L=function(){function t(t,n,a){var o=!1;return t.each(function(t){var i=r(n,a.paneId,e(this).data("tab")[a.paneId]);if(i>-1&&i!==t)return o=!0,!1}),o}function n(e,t){for(var n=e.length-1,r=-1,a=0,o=0;-1===r&&o>=0;)((o=t+ ++a)<=n&&!e.eq(o).hasClass("disabled")||(o=t-a)>=0&&!e.eq(o).hasClass("disabled"))&&(r=o);return r}function r(e,t,n){var r=-1;return e.some(function(e,a){if(e[t]===n)return r=a,!0}),r}function a(t,n,r){t.data({tab:e.extend({},n[r]),index:r})}return{didTabOrderChange:t,getIndexOfClosestEnabledTab:n,getTabIndexByPaneId:r,storeDataOnLiEl:a}}(),E={destroy:function(){return this.each(S)},init:function(t){var n=this,r=n.length-1,a=e.extend({},e.fn.scrollingTabs.defaults,t||{});return a.tabs?n.each(function(t){i(e(this),a,t " class="btn btn-default" style="position: absolute; right: 10px; top: 5px;"> body{padding-top:0;}'; } echo ''; return ''; } if (!empty($advancedCustomUser->keepViewerOnChannel)) { if (!empty($_GET['channelName'])) { _session_start(); $_SESSION['channelName'] = $_GET['channelName']; } if (!empty($_GET['leaveChannel'])) { _session_start(); unset($_SESSION['channelName']); } } session_write_close(); global $includeDefaultNavBar, $global, $config, $advancedCustom, $advancedCustomUser; if (!isset($global['systemRootPath'])) { require_once '../videos/configuration.php'; } require_once $global['systemRootPath'] . 'objects/user.php'; require_once $global['systemRootPath'] . 'objects/category.php'; $_GET['parentsOnly'] = "1"; if (empty($_SESSION['language'])) { $lang = $config->getLanguage(); if(empty($lang)){ $lang = 'us_EN'; } } else { $lang = $_SESSION['language']; } $thisScriptFile = pathinfo($_SERVER["SCRIPT_FILENAME"]); if (empty($sidebarStyle)) { $sidebarStyle = "display: none;"; } $includeDefaultNavBar = true; AVideoPlugin::navBar(); if (!$includeDefaultNavBar) { return false; } if(!empty($_GET['avideoIframe'])){ // comes from avideoModalIframe(url) javascript ?> userMustBeLoggedIn) && !empty($advancedCustomUser->userMustBeLoggedInCloseButtonURL)) { ?> userMustBeLoggedIn) && empty($advancedCustom->disableNavbar)) || $thisScriptFile["basename"] === "signUp.php" || $thisScriptFile["basename"] === "userRecoverPass.php") || User::isLogged()) { $updateFiles = getUpdatesFilesArray(); ?> underMenuBarHTMLCode->value)) { echo $advancedCustom->underMenuBarHTMLCode->value; } } else if ($thisScriptFile["basename"] !== 'user.php' && empty($advancedCustom->disableNavbar)) { } +echo '', AVideoPlugin::navBarAfter(), ''; unset($_GET['parentsOnly']); ?>